dev-develop
dev-develop https://github.com/codeChap/crontabPHP Cronjob manager
MIT
The Requires
- php >=5.3.0
by Derrick Egersdorfer
cronjob cron crontab
Wallogit.com
2017 © Pedro Peláez
PHP Cronjob manager
Simple, independant and local PHP Crontab package, (*1)
The package helps you manage your local cron jobs using PHP. You can list, append and remove your jobs and set your log file., (*2)
Should work on monst Linux flavoured systems., (*3)
Use composer to install it or simply include the file somewhere: require("crontab/src/Crontab/Crontab.php");, (*4)
Append two new jobs and set them to run every minute:, (*5)
$cron = new \Crontab\Crontab();
$cron->setMinute("*");
$cron->setHour("*");
$cron->setDayOfMonth("*");
$cron->setMonth("*");
$cron->setDayOfWeek("*");
$cron->append(array(
"date",
"ls -all"
)
);
$commandsList = $cron->execute();
Appends a new job to the current cronjob list, (*6)
Parameters: $command : String or array of commands., (*7)
$cron = new \Crontab\Crontab();
$cron->setMinute("*");
$cron->setHour("*");
$cron->setDayOfMonth("*");
$cron->setMonth("*");
$cron->setDayOfWeek("*");
$cron->append("date");
$cron->execute();
Removes a job from the current cronjob list. You must recreate the exact job to remove it., (*8)
Parameters: $command : String or array of commands, (*9)
$cron = new \Crontab\Crontab();
$cron->setMinute("*");
$cron->setHour("*");
$cron->setDayOfMonth("*");
$cron->setMonth("*");
$cron->setDayOfWeek("*");
$cron->remove("date");
$cron->execute();
Return a current list of jobs with there hashed keys, (*10)
$cron = new \Crontab\Crontab();
$cron->setMinute("*");
$cron->setHour("*");
$cron->setDayOfMonth("*");
$cron->setMonth("*");
$cron->setDayOfWeek("*");
$cron->remove("date");
$cron->execute();
Removes a job from the current cronjob list by a hash key. Found by running execute() or getJobs(), (*11)
Parameters: $key : String or array of keys, (*12)
$cron = new \Crontab\Crontab();
$cron->removeByKey("1231231231231231231");
$cron->execute();
Applies and writes the new cronjob list., (*13)
$cron->setMinute("*");
$cron->setHour("*");
$cron->setDayOfMonth("*");
$cron->setMonth("*");
$cron->setDayOfWeek("*");
$cron->append("date");
$cron->execute();
Simply removes all running jobs by executing crontab -r, (*14)
$cron = new \Crontab\Crontab();
$cron->clear();
Settings can also be applied to the constuct method like so:, (*15)
$conf = array(
'minute' => '*',
'hour' => '*',
'dayOfMonth' => '*',
'month' => '*',
'dayOfWeek' => '*',
'logFile' => 'log.txt',
'tmpFile' => 'jobs.txt'
);
$cron = new \Crontab\Crontab($conf);
setMinute($m) : Sets the minute. setHour($h) : Sets the hour. setDayOfMonth($dom) : Sets the date of the month. setMonth($m) : Sets the month. setDayOfWeek($dow) : Sets the day of the week.
setLogFile($v) : Sets the log file and will attempt to create it. The default is /dev/null ie: nothing logged setTmpFile($v) : Sets the tempory file used by crontab to read from, this file is automatically removed. The default is "jobs.txt"
Execute this job in 5 minutes from now., (*16)
$cron = new \Crontab\Crontab();
$cron->minuteFromNow(5);
$cron->execute();
A Google search should provied plenty of links but check out: Kevin van Zonneveld's blog if you need help., (*17)
Use this library at your own risk., (*18)
PHP Cronjob manager
MIT
cronjob cron crontab