4

I’ve been trying to get whenever running on an ec2 instance that was created with ec2 on rails.

When I deploy with Capistrano it indicates that the crontab was written, but when I log into the server and run crontab -l it does not seem to have been changed.

If I go into the release folder and manually run whenever --write-crontab then run crontab -l - it gets updated properly.

Any ideas what could be causing this?

Capistrano is not indicating any errors so not sure how to debug, have tried a billion permutations and combinations and nothing changes.

Muntasim
  • 6,689
  • 3
  • 46
  • 69
Gordon Isnor
  • 2,065
  • 1
  • 19
  • 32
  • 1
    Just to be sure, do you check the cron jobs of the right user? Eg, you log in as root, but your app is running as deploy. Check this, e.g. by running `sudo crontab -l -u deploy`. – Stan Sidel Aug 06 '14 at 03:24
  • Thanks for the tip @SSidelnikov! I asked this question five years ago! Probably I should have marked that my own answer was adequate at the time, was new to Stack Overflow at the time. – Gordon Isnor Aug 06 '14 at 12:28

3 Answers3

1

you should be able to just require the whenever capistrano command in your cap deploy file like so:

require 'whenever/capistrano'

if you're using bundler, you'll need to add this as well:

set :whenever_command, 'bundle exec whenever'

hubert
  • 278
  • 3
  • 12
0
namespace :deploy do
  desc "write the crontab file"
  task :write_crontab, :roles => [:db_admin] do  
    run "cd #{release_path} && sudo -u root  whenever --write-crontab #{application}"
  end  
end

Or there is also apparently a -user option in whenever that can help with this.

Gordon Isnor
  • 2,065
  • 1
  • 19
  • 32
0

This is not related to OP, but according to this issue, Capistrano 2.11.1 needs Whenever 0.7.3 in order to fix the issue.

lulalala
  • 17,572
  • 15
  • 110
  • 169