News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthew Weier O'Phinney:
Deployment with Zend Server (Part 2 of 8)
August 29, 2014 @ 11:55:04

Matthew Weier O'Phinney has posted the second part of his series with some tips around application deployment with Zend Server. In this latest post he shares his second tip related to recurring jobs.

This is the second in a series of eight posts detailing tips on deploying to Zend Server.The previous post in the series detailed getting started with zf-deploy to create ZPK packages to deploy to Zend Server. Today, I'm looking at how to created scheduled/recurring jobs using Zend Server's Job Queue; think of this as application-level cronjobs.

Instead of running the jobs as cron tasks (which may or may not be installed if there's multiple servers), he opts for a software-based approach. He walks you through the use of the Zend Server Job Queue to create a simple reoccurring execution to run a PHP script at a certain time. He includes some code examples with one showing just the scheduling of a job and the other showing how to detach previous jobs and add only the new ones that weren't scheduled before.

0 comments voice your opinion now!
deployment zendserver tip series part2 cron reoccurring jobs

Link: http://mwop.net/blog/2014-08-28-zend-server-deployment-part-2.html

DevShed.com:
PHP Best Methods for Running Scheduled Jobs
June 28, 2012 @ 11:01:49

On DevShed.com today there's a new article posted looking at methods for running scheduled jobs based on responses to this forum post.

I have a webpage form that requires a date and time to be submitted. When it's submitted I need the back-end to run a script at the time and date specified. Have you ever needed to do something like this?

Some recommendations already posted include:

  • The UNIX "at" command
  • Setting up a queue system to manage the processes (using something similar to Gearman
  • Setting up a cron job to handle the periodic execution of the script.
0 comments voice your opinion now!
execute scheduled job cron queue at unix opinion


PHPBuilder.com:
My Automated PHP Scripts for Creating FTP Connections to a Remote Server
June 19, 2012 @ 10:41:57

PHPBuilder.com has posted a new tutorial about creating automated FTP scripts to pull down information from a remote server (using FTP streams).

In 2007 I began working on a website project for an investment company in my hometown of Cleveland, Ohio USA. The purpose of this website was to automatically download financial data of traded securities from two (2) remote Web servers. [...] Both of these PHP scripts were set up on the Web server's "crontab manager" to automatically run at a set time each business day.

Code is included showing how to connect to the remote service (via curl) with a "ftp" stream-based URL as the location. Also included is an example using a fopen call to the URL and inserting the resulting data into their tracking tables. The other script pulls the data out and adds a new record to a transactions table for the current day.

0 comments voice your opinion now!
ftp tutorial connection transaction mysql cron automation


Michael Dowling's Blog:
Cron Expression Parsing in PHP
June 04, 2012 @ 12:03:52

Michael Dowling has shared a new tool on his blog today - a parser for crontab files that can be used directly from within PHP - cron-expression.

When faced with the task of creating the cron expression parsing part of this system, I searched high and low for an existing implementation in PHP that implemented the full feature set of a modern cron expression. Based on the context of this article, you probably guessed that I didn't find one. I posted the original code I came up with to StackOverflow and eventually open sourced the project.

Not only does the tool let you read from the cron files but it also lets you do other fun things like:

  • Determine the next run date for the program
  • Calculate the next X number of run dates/times
  • Find the last run date of the program
  • Check to see if an expression will run on a certain date

The full source for the tool is available for download (and pull requests!) over on github.

0 comments voice your opinion now!
cron parse tool cronexpression example


PHPMaster.com:
How I Faked Scheduled Database Dumps Without Cron
March 27, 2012 @ 11:06:05

On PHPMaster.com today there's a new tutorial about a way to simulate cron jobs to dump the contents of a database with a simple script that fires off based on the last login time of a certain user (using the MySqlDumper tool).

My program required a accurate username and password to present its features to the user, and there is one predefined user who is idle most of the time and does just two things: wipe stale database entries and restore the database when needed. According to my login procedure, each time a user successfully logs in the system automatically updates the last login date to the current date. And that was the hint I desperately needed.

A brief snippet of code is included showing how he implemented the solution - MySQL commands and parameters defined in constants and called only when the last login time is less than "today".

0 comments voice your opinion now!
cron mysqldumper tutorial last login


Justin Carmony's Blog:
PHP Workers with Redis & Solo
January 11, 2012 @ 11:50:52

In this latest post to his blog Justin Carmony shares some of his experience using Redis and Solo to asynchronously run queries and return data without the user having to wait.

Sometimes there are situations when you want to parallel process things. Other times you might have a list of tasks to accomplish, and you don't want to make the user wait after pressing a button. This is where "Workers" can come in. They are independent scripts that run along side of your application, performing tasks, or "jobs."

Solo is a very basic Perl script that ensures only one process of a type is running at once. Using this and a PHP library called predis, he shows how to set up workers and add items to your processing queue. The workers themselves run on a cron job and connect to the queue server to see what they need to do. He also throws in some "bells and whistles" - extras that can enhance your worker system: queue monitoring, version numbering and killing workers based on a hash value.

His code examples are posted on his github account and a screencast is included in the post to show the system in action.

0 comments voice your opinion now!
redis solo cron tutorial queue worker


SitePoint.com:
Scheduling Tasks in WordPress a Plugin Developer's Guide
July 21, 2010 @ 09:45:17

On SitePoint.com there's a new tutorial posted in their "PHP & MySQL tutorials" section about using a feature of WordPress that some might not know about but can be extremely handy when you need it - using WordPress tasks.

Scheduling the execution of certain functions at a time in the future is a key feature of the WordPress API, having been introduced in WordPress version 2.0. It's also a topic that's poorly understood by many developers, as it's only briefly covered in WordPress's documentation. Apart from facilitating maintenance tasks, scheduling code to be executed in the future opens up a lot of interesting possibilities for plugin developers.

He talks a bit about how the WordPress tasks work (via the wp-cron.php script) and the two types of tasks - one-off and recurring. He includes code and examples of how to set up each and some other handy features like custom timing for tasks, getting the list of scheduled tasks and a few things to watch out for when working with the feature.

0 comments voice your opinion now!
wordpress schedule task cron developer tutorial


Adam Jensen's Blog:
Cron tasks in Zend Framework apps
January 13, 2010 @ 08:45:41

In this new post to his blog Adam Jensen looks at creating cron jobs with the help of the Zend Framework without having to load up the entire MVC architecture to get there.

So, we're going to need a new application bootstrap and entry point, one that eschews the MVC routing and dispatch process in favor of something simpler. Essentially, all we'll need is to be able to run an arbitrary collection of cron "task plugins," the list of which can be configured in plain text via any of the various Zend_Config formats (e.g., the default application.ini file).

He starts with the base functionality, a task plugin interface that allows you to set up a "framework" to run the tasks in. He also creates a simple cron service that handles the execution of the tasks (this is the main executable) and includes the code for creating the bootstrap for the Zend Framework to understand how to use it all. Then to create a new task, all you have to do is extend the CronInterface.

0 comments voice your opinion now!
zendframework task cron tutorial plugin interface


Vinu Thomas' Blog:
Fixing the "Missed Schedule" problem in Wordpress
December 31, 2009 @ 13:13:28

Vinu Thomas has posted a tip for WordPress users working with scheduled posts and the "Missing Status" status that's caused by a bug in WordPress.

Ever since the upgrade to Wordpress 2.9, I've been having a problem in the scheduled posts in Wordpress. Everytime I set a post to be scheduled in the future, it used to miss the scheduled time and never get posted. When I checked the status of these posts in the posts admin area, each of these posts had the status "Missed Schedule" next to them.

To correct the issue, you need to make a change to the cron.php script for your installation (in wp-includes) to change the default timeout by quite a bit to ensure that the remote call has plenty of time to finish. It seems its related to the version of PHP's curl extension that's compiled into the web server installation.

0 comments voice your opinion now!
wordpress cron missed schedule timeout


Abhinav Singh's Blog:
How to use locks in PHP cron jobs to avoid cron overlaps
December 29, 2009 @ 12:45:31

In this new post from Abhinav Singh on how to use file locking to keep your cron jobs from trying to use the same resources.

Cron jobs are hidden building blocks for most of the websites. They are generally used to process/aggregate data in the background. However as a website starts to grow and there is gigabytes of data to be processed by every cron job, chances are that our cron jobs might overlap and possibly corrupt our data. In this blog post, I will demonstrate how can we avoid such overlaps by using simple locking techniques. I will also discuss a few edge cases we need to consider while using locks to avoid overlap.

He includes some sample code - both the class to create the functionality and a script showing how to make use of it (and, of course, an example of it in use).

0 comments voice your opinion now!
cron file lock tutorial



Community Events





Don't see your event here?
Let us know!


introduction library laravel community list api update package release podcast series language interview zendserver framework symfony install deployment tips opinion

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework