0

I am trying to set up CRON jobs on Amazon EC2 with using the Whenever gem. In the schedule.rb is following:

 set :output, "/home/my_deploy_name/my_deploy_name/current/log/cron_log.log"

 every 2.minutes do
   puts "It's working !!!"
 end

and in the deploy.rb this:

...
set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
after 'deploy:create_symlink', 'whenever:update_crontab'
after 'deploy:rollback', 'whenever:update_crontab'

When I deploy this code to EC2 and check crontab -l, the output is:

no crontab for ubuntu

When I run crontab -e, the file is not edited.

What is wrong here? What the CRON job doesn't run on EC2 every 2 minutes?

user984621
  • 46,344
  • 73
  • 224
  • 412

1 Answers1

0

Some options to try:

1) Log into the server and run:

bundle exec whenever --update-crontab

and check your crontab.

2) You don't need to set the before and after callbacks. The capistrano recipe does that for you:

https://github.com/javan/whenever/blob/master/lib/whenever/capistrano.rb

Capistrano::Configuration.instance(:must_exist).load do
  # Write the new cron jobs near the end.
  before "deploy:finalize_update", "whenever:update_crontab"
  # If anything goes wrong, undo.
  after "deploy:rollback", "whenever:update_crontab"
end
Farley Knight
  • 1,795
  • 1
  • 13
  • 17
  • I am using `gem 'whenever', :require => false`, also updated the **recipes** there, but still **no crontab for ubuntu**. – user984621 Sep 30 '13 at 13:10
  • What version of `whenever` are you using? – Farley Knight Sep 30 '13 at 13:13
  • I mean, when I just deploy a code to EC2 with capistrano, the cron jobs should automatically work on EC2 itself? There is not needed to activate it or so? On localhost I see the output for **crontab -l**, but not on EC2. – user984621 Sep 30 '13 at 13:13
  • The last one - `0.8.4` – user984621 Sep 30 '13 at 13:14
  • Updated my answer. You should try doing it manually. It's possible you're getting an error and can only be seen while logged into your EC2 instance. – Farley Knight Sep 30 '13 at 13:22
  • Thank you. When I run `whenever --update-crontab`, I will get error: `Sorry, command-not-found has crashed! Please file a bug report at: https://bugs.launchpad.net/command-not-found/+filebug Please include the following information with the report: command-not-found version: 0.2.44` – user984621 Sep 30 '13 at 13:31
  • Sorry, forgot `bundle exec`. Edited my answer. – Farley Knight Sep 30 '13 at 13:33