Deploying scheduled jobs with PEAR
| From: | Tim Jackson | Date: | Thu, 10 Dec 2009 15:30:53 +0000 |
| Subject: | Deploying scheduled jobs with PEAR | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-53091@lists.php.net to get a copy of this message | ||
Hi,
Consider the situation where you have one or more applications installed using PEAR, and each of them need to set up some scheduled jobs ("cron jobs").
Does anyone have a good existing solution for this using PEAR?
The logical way I can come up with doing it so far is this:
- create a new file role called "scheduledjob" or something, which
installs into a special directory
- define (by convention) that files installed using that role are in a
specific format (say, for example, the typical crontab format like
"*/5 * * * * php /path/to/script.php"). Naturally, these would almost
certainly need to be pre-processed with tasks:replace etc. to fill in the
file paths, php bin location etc.
- use a custom task to, on installation of a file with role "scheduledjob",
parse it and set up cron (or the equivalent on other platforms, e.g.
Windows Scheduled Tasks).
Is there any existing package to do the work within that latter point to set up the job? I was looking for something like System_Cron or System_ScheduledTask but didn't find anything. (If not, then it could potentially be a new PEAR lib, for example System_ScheduledTask, with drivers like System_ScheduledTask_Cron [possibly with several variants for the various crons out there], System_ScheduledTask_Windows etc. I already have some sample code for this for Linux crons.)
But does anyone have any other well-established solution to this? Even pearweb just has the scripts in a directory called "cron", marked with role "www". As far as I can tell, these have to be installed manually; there doesn't seem to be anything in the post-installation tasks to do it.
N.B. I'm quite keen on using "standard" system schedulers rather than solutions like "every X hits to my website, trigger some task" on the basis that they are proven and don't rely on some external mechanism.
Thanks,
Tim