Unable to run cronjob using whenever in rails 3 -
i follow steps whenever reference 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 runner "user.weekly_update" end
in gemfile
gem 'whenever', :require => false
output of 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 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 schedule file converted cron syntax; crontab file not updated. ## [message] run `whenever --help' more options.
in user model have definition self.weekly_update
def self.weekly_update puts "cronjobs called in every minutes" end
your correct, saying cron job print in background, doing , able observe it.
instead should try create or destroy records feel changes think :)
Comments
Post a Comment