PHP Classes


Recommend this page to a friend!
  Classes of Jo Giraerts  >  cjpa's Crontab Class  >  README  >  Download  
Role: Documentation
Content type: text/plain
Description: Some help
Class: cjpa's Crontab Class
Manipulate cron tab files to schedule programs
Author: By
Last change:
Date: 17 years ago
Size: 1,029 bytes


Class file image Download
cjpa's Crontab-class (c)2003-2004 (

Some notes concerning the crontab-class.

The class is pretty thoroughly documented, so i won't go into specifics here. Windows-users: Bad luck, this won't work on your system unless you have installed Cygwin and probably even then you'll need to adapt this class a bit.

The following example will open the crontab-file of the user who is running the script, take the last entry from her crontab and add another crontab, 5 minutes later that does "ls -al".

<--- SNIP --->

#!/usr/local/bin/php -q
	include_once "Crontab.php";

        $cron = new Crontab(get_current_user());
        $min = ($cron->crontabs[count($cron->getByType(CRON_CMD))][minute] + 5) % 60;
        $hour = $cron->crontabs[count($cron->getByType(CRON_CMD))][hour];

        if ($min < $cron->crontabs[count($cron->crontabs)-1][minute])
                $hour = ($hour+1) % 24 ;

        $cron->addCron($min, $hour, "*", "*", "*", "ls -al");

<--- SNIP --->

For more information send a message to info at phpclasses dot org.