开发者

Setting cron tab for ROR pages

开发者 https://www.devze.com 2023-03-16 11:34 出处:网络
I am running rails 3 vers开发者_运维问答ion . I need to set crons in the server I dont want to use wget method in crons. Instead of that need to run the files from the server. I need to run the ROR p

I am running rails 3 vers开发者_运维问答ion . I need to set crons in the server

I dont want to use wget method in crons. Instead of that need to run the files from the server. I need to run the ROR page through terminal in crons

Is there any way for this

Thanks


You can take a look to the whenever gem:

https://github.com/javan/whenever

Shortly you can call a method in your code doing something like this (as explained on the gem homepage)

every 1.day, :at => '4:30 am' do 
  runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
end


I got it using Rake

I just created a rake file inside the tasks folder end executed the following command

"cd :path && script/rails runner -e :environment ':task' :output"

0

精彩评论

暂无评论...
验证码 换一张
取 消