1

I am using whenever to fire a rake task every 5 minutes for my app.

schedule.rb:

every 5.minutes do   
rake "audit",
:environment => 'development'
end

"whenever" in console:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /Users/john/Sites/rambler && RAILS_ENV=development bundle exec rake audit --silent'

"rake audit" in console works properly.

So all looks good .... except it doesn't work. Nothing happens every five minutes.

Is this because I am trying to run it in development / local?

Thanks!

John R
  • 301
  • 3
  • 14

2 Answers2

1

You need to update your cron file every time you change it.

After you have addded your cron job do this:

whenever --update-crontab 'project_name'

Also I only found whenever working fine in production mode only.

UPDATE:

I have found that we can use whenever in development mode also. Just add

set :environment, "development"
set :output, {:error => "log/error.log", :standard => "log/cron.log"}  

to your scehdule.rb file. ( The log one is optional but still you can use that for testing purpose)

mrudult
  • 2,480
  • 3
  • 35
  • 54
0

Finally I have solved how to run the gem Whenever. It's working good on production, but not in development mode (I think that to working good in dev mode you must do some tricks). see this answer for working in dev mode: Cron not working in Whenever gem

Then, these are the processes to do:

  1. install the gem
  2. write your scheduler.rb file
  3. push to the remote server
  4. login to the remote server (for example with ssh)
  5. see if whenever is good uploaded by running in terminal: whenever
  6. update whenever crontab by running: whenever --update-crontab
  7. restart the server crontab (for example in ubuntu): sudo service cron restart
  8. check if crontab are good implemented on the server: crontab -l

That is!

Community
  • 1
  • 1
damoiser
  • 6,058
  • 3
  • 40
  • 66