Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the whenever gem preserve existing lines in a crontab file?

I am using:

  • Ruby 1.9.2
  • whenever 0.7.2
  • capistrano 2.9.0
  • capistrano-ext 1.2.1

I am using whenever in conjunction with Capistrano on deploys to manage my crontab files.

I noticed that it completely rewrites my crontab files each time.

I'd like to be able to set environment variables in cron to control PATH and MAILTO settings, which are regular cron environment variables.

Is there a way to make whenever not overwrite the entire crontab file, so that I can add customizations to my crontab file and be sure that they will persist?

like image 684
Wes Gamble Avatar asked Apr 11 '12 19:04

Wes Gamble


1 Answers

Yes, you can do this. You'll just need to assign an identifier to the task being written to crontab:

whenever --update-crontab some_identifier_name

It will generate an entry in crontab like this:

# Begin Whenever generated tasks for: some_identifier_name
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /var/www/test/releases/20120416183153 && script/rails runner -e production '\''Model.some_method'\'' >> /tmp/cron_log.log 2>&1'

# End Whenever generated tasks for: some_identifier_name

Then whenever you call the command above it will only update where it finds the identifier you specified.

like image 83
Calvin Avatar answered Sep 21 '22 14:09

Calvin