PHP Classes
elePHPant
Icontem

cjpa's Crontab Class: Manipulate cron tab files to schedule programs

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2004-11-29 (10 years ago) RSS 2.0 feedStarStarStar 55%Total: 2,725 All time: 1,311 This week: 1,136Up
Version License Categories  
crontab 1.0GNU Lesser Genera...Time and Date, Unix
Description Author  

This class interfaces with the Unix/Linux crontab program to parse, manipulate and save the execution of scheduled programs.

You can add, delete, update crontab entries for a given user. It supports comments as well as the special commands (DAILY, WEEKLY, etc..)

Picture of Jo Giraerts
Name: Jo Giraerts <contact>
Classes: 3 packages by
Country: Belgium Belgium
Age: ???
All time rank: 8474 in Belgium Belgium
Week rank: 450 Up1 in Belgium Belgium Up

Details provided by the author  
cjpa's Crontab-class (c)2003-2004 (cjpa@audiophile.com)

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
<?php 
	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");
        $cron->writeCrontab();
?>

<--- SNIP --->


  Files folder image Files  
File Role Description
Plain text file Crontab.php Class Main Class
Accessible without login Plain text file README Doc. Some help

 Version Control Unique User Downloads Download Rankings  
 0%Total:2,725All time:1,311
 This week:0This week:1,136Up
User Ratings User Comments (1)  
 All time
Utility:81%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:68%StarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:55%StarStarStar
Rank:1260