Re: Deploying scheduled jobs with PEAR
| From: | Brett Bieber | Date: | Mon, 14 Dec 2009 14:32:27 +0000 |
| Subject: | Re: Deploying scheduled jobs with PEAR | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-53097@lists.php.net to get a copy of this message | ||
Hi Tim,
On Thu, Dec 10, 2009 at 9:30 AM, Tim Jackson <lists@timj.co.uk> wrote:
> 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?
I don't know of any existing solution.
> 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).
Sounds good.
> 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.)
This sounds like a good pepr project.
> 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.
Correct, right now those require manual scheduling.
> 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
I'd submit something to pepr. First the basics like the scheduling
scripts to add, remove, and modify scheduled tasks, then work towards
supporting the custom roles.
This sounds like a really useful feature for full-stack applications -
something I might take advantage of myself.
--
Brett Bieber