Search code examples
rubycapistranocron

Creating crontab via Capistrano instead of using crontab -e


I would like to include cron tasks in my Capistrano deployment files instead of using the following command to manually edit the crontab file:

crontab -e [username]

Is there a script I could use within the Capistrano run command to set the contents of the crontab?


Solution

  • On my linux box

    crontab -u userName -l > fileName
    

    lists the crontab file for userName in fileName.

    Then I would use a ruby (or another language) script to update the file.

    Finally I would use

    crontab -u userName fileName
    

    to update the crontab for userName