Create a cronjob in ruby on rails by using whenever gem.
set :environment, "development"
set :output, {:error => "log/cron_error_log.log" , :standard => "log/cron_log.log" }
every '* * * * * ' do
command "puts 'you can use raw cron syntax too'"
end
Also update crontab it also add in list of crontab. But when I test it manually by
/home/haseebahmad/projects/social/config/schedule.rb
it gives error
/home/haseebahmad/projects/social/config/schedule.rb: line 19: every: command not found
/home/haseebahmad/projects/social/config/schedule.rb: line 20: puts 'you can use raw cron syntax too': command not found
/home/haseebahmad/projects/social/config/schedule.rb: line 21: end: command not found
It doesn't work properly, how can I solve it
every
function is coming from. Rails will autoload your gems and not make you to use arequire
statement to include to gem. If you want to test manually by running the script, you will need to include therequire
statement that brings the gem into scope.