0

I am using Whenever gem with rails. For some reason the first cronjob does not work. If i copy paste the command into the shell manually, it works as it should.

The second "touch testing123.txt" also works fine.

I have no idea why the GiftPackage.do_scheduled_deliveries rails method does not run. I'm really at a loss right now.. any help would be greatly appreciated!

# Begin Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && script/rails runner -e staging '\''GiftPackage.do_scheduled_deliveries'\'''
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && touch testing123.txt'
# End Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb

Thanks! :)

4

2 回答 2

0

尝试在作业之前设置 PATH 变量,您的 cron 可能无法找到 ruby​​ :

例如 :

PATH=/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/$
# Begin Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && script/rails runner -e staging '\''GiftPackage.do_scheduled_deliveries'\'''
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && touch testing123.txt'
# End Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb
于 2013-02-01T00:16:31.603 回答
0

您很可能在应用程序本身内遇到错误。

第一步是,使用登台环境在控制台中运行任务。

其次是检查 cron 日志,看看它是否输出任何错误。

您可以通过将以下内容添加到 schedule.rb 文件来设置何时记录输出;

set :output, "/[path to log]/cron.log"

这应该可以帮助您更接近找到解决方案。

于 2013-02-01T00:09:54.097 回答