Deployer: Add cron management to deployer

Created on 22 Jan 2018  路  6Comments  路  Source: deployphp/deployer

| Q | A
| ----------------- | ---
| Issue Type | Feature Request

Description

Add cron management to deployer like: http://docs.ansible.com/ansible/latest/cron_module.html

feature

All 6 comments

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JonasDoebertin picture JonasDoebertin  路  4Comments

jolipixel picture jolipixel  路  4Comments

dima-stefantsov picture dima-stefantsov  路  5Comments

sweebee picture sweebee  路  3Comments

ElForastero picture ElForastero  路  3Comments