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

1

6

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?

Feoff answered 11/4, 2012 at 19:0 Comment(0)
P
12

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.

Pathogenic answered 17/4, 2012 at 19:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.