| Q | A
| ----------------- | ---
| Issue Type | Feature Request
Add cron management to deployer like: http://docs.ansible.com/ansible/latest/cron_module.html
@antonmedv Is there any progress or ETA for this issue?
Some progress already done on this issue (but not in public repo). Now I'm actively working on Deployer CI project, after will be more time for v7.
For the time being I created a custom task that reads cronjobs from a local txt file and installs them on the server.
Modify to your liking.
task('deploy:cronjobs', function () {
run("echo '' | crontab -");
$cron_file = file('cronjobs.txt');
foreach ($cron_file as $line) {
$line = trim(str_replace("\n", "", $line));
run("(crontab -l; echo \"".$line."\") | crontab -");
}
})->desc('Install the necessary cronjobs');
We solved it at @JCID by adding the complete crontab file to the GIT repository and load the full file from there (only in production mode).
task(
'cronjob:install',
function () {
if (Context::get()->getEnvironment()->get('env') === 'prod') {
run('crontab /path/to/the/crontab/file');
}
}
)->desc('Install cronjobs');
I hope it helps you further on! Cheers!
task('cronjob:install', function () {
run('crontab {{release_path}}/conf/crontab.conf');
})->desc('Install cronjobs')->onStage('prod');
For people finding this on Google and wants a little more functionality than the recipe in the contribs folder, here is a lib that will help you out: https://github.com/Setono/deployer-cron