Rake任务与Cron作业 [英] Rake Task with Cron Job
问题描述
我试图设置cron作业来每天运行一个rake任务。我目前有以下的cron工作(注意,时间是所有*的,因为我想要它每分钟运行测试)
I am trying to set up cron job to run a rake task daily. I currently have the following cron job (note, the time is all *'s because I want it to run every minute while testing)
* * * * * cd /home/jon/thestockenator/lib/tasks/ && ./get_current_data.sh
在shell脚本中,我将整个PATH添加到cron运行它并调用rake test_task。
In the shell script I added the entire PATH to whatever the path is when cron runs it and call rake test_task.
我设置了一个基本的rake任务,只是输出一些文本(因为我的真正的需要一段时间运行)
I set up a basic rake task that simply outputs some text (because my real one takes a while to run)
task :test_task do
puts "this is a rake task"
end
在cron作业中运行时,cron作业肯定会运行,而 p>
The cron job definitely runs and which rake
works when run in the cron job.
推荐答案
我通过将此脚本添加到脚本来修复它:
I fixed it by adding this to the script:
source〜/ .rvm / scripts / rvm
这篇关于Rake任务与Cron作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!