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
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With