Is it possible to use PHP to create, edit and delete crontab jobs?
I know how to list the current crontab jobs of the Apache user:
$output = shell_ex
We recently prepared a mini project (PHP>=5.3) to manage the cron files for private and individual tasks. This tool connects and manages the cron files so you can use them, for example per project. Unit Tests available :-)
Sample from command line:
bin/cronman --enable /var/www/myproject/.cronfile --user www-data
Sample from API:
use php\manager\crontab\CrontabManager;
$crontab = new CrontabManager();
$crontab->enableOrUpdate('/tmp/my/crontab.txt');
$crontab->save();
Managing individual tasks from API:
use php\manager\crontab\CrontabManager;
$crontab = new CrontabManager();
$job = $crontab->newJob();
$job->on('* * * * *');
$job->onMinute('20-30')->doJob("echo foo");
$crontab->add($job);
$job->onMinute('35-40')->doJob("echo bar");
$crontab->add($job);
$crontab->save();
github: php-crontab-manager