This is the code in my schedule file. I am using 1 min just to test whether its working or not.
every 1.minutes do
runner "User.update_all('daily_sms_count' = 0 )"
end
from terminal i setup
whenever --set environment=development --update-crontab 1mintesting
Whats the issue?
Are you using RVM? If so, Whenever generates a crontab entry like this:
* * * * * /bin/bash -l -c
'cd /Users/myuser/Documents/Projects/foo && script/rails runner -e
development '\''User.update_all("daily_sms_count" = 0 )'\'''
This means that it won't necessarily be using your project's version of Ruby and associated gemset as it spins off a new bash shell. To make this work, you need to add an appropriate .rvmrc
file to your project's root folder. This way, the cd /Users/myuser/Documents/Projects/foo
part of the generated crontab entry will ensure that the appropriate RVM settings are used. Just make sure that when you add the .rvmrc
file, cd..
and back into the project to make RVM recognize your project's .rvmrc
.
If you are not using RVM, run crontab -l
, and copy the generated entry, and run it from terminal to see if it runs with no errors or not.
If you are using Mac, cron
will send log messages to your mailbox and you can view them using the mail
command.
If these tricks didn't work, give me more details about your working environment (OS, RVM, etc.) so that I can help you more.