4

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?

Mohit Jain
  • 43,139
  • 57
  • 169
  • 274
  • i think whenever does not run properly in development mode. I had also problems with that. did you try to start you server in production and see if it works? – tmaximini Aug 08 '11 at 12:02
  • @frank yaa.. u are right.. its not working on development mode.. worked perfectly fine in server.. thanks bro.. – Mohit Jain Aug 09 '11 at 10:01

1 Answers1

6

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.

Behrang
  • 46,888
  • 25
  • 118
  • 160
  • the `mail` command works for me on a mac. I'm only not seeing the messages appear every 10,20 minutes/hours/days. Why is that? – Biketire Jun 19 '13 at 12:10