Unable to run cronjob using whenever in rails 3

谁说我不能喝 提交于 2019-12-10 05:00:33

问题


i follow all the steps for whenever with reference to https://github.com/javan/whenever

in schedule.rb

require 'yaml'
set :environment, 'production'
set :output, {
    :error    => "/log/error.log",
    :standard => "/log/cron.log" 
}

every 1.minute do
   runner "User.weekly_update"
end

in gemfile

gem 'whenever', :require => false

output of some command

localhost:~/project$ whenever -i

[write] crontab file updated

localhost:~/project$ crontab -l

# Begin Whenever generated tasks for: /home/bacancy/project/config/schedule.rb
* * * * * /bin/bash -l -c 'cd /home/bacancy/project && script/rails runner -e     production '\''User.weekly_update'\'' >> /log/cron.log 2>> /log/error.log'

# End Whenever generated tasks for: /home/bacancy/project/config/schedule.rb

# Begin Whenever generated tasks for: store
* * * * * /bin/bash -l -c 'cd /home/bacancy/project && script/rails runner -e  development '\''User.weekly_update'\'''

# End Whenever generated tasks for: store

# Begin Whenever generated tasks for: lapulguilla

# End Whenever generated tasks for: lapulguilla

and then i type

localhost:~/project$ whenever

* * * * * /bin/bash -l -c 'cd /home/bacancy/project && script/rails runner -e    production '\''User.weekly_update'\'' >> /log/cron.log 2>> /log/error.log'

## [message] Above is your schedule file converted to cron syntax; your crontab file  was not updated.
## [message] Run `whenever --help' for more options.

In User model i have definition self.weekly_update

def self.weekly_update
  puts "cronjobs is called in every minutes"
end 

回答1:


Your everything is correct, its just that you are saying to cron job to print something in background, so it is doing that and you are able to observe it.

Instead you should try create or destroy some records to feel the changes i think :)



来源:https://stackoverflow.com/questions/15831603/unable-to-run-cronjob-using-whenever-in-rails-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!