问题
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
In the shell script I added the entire PATH to whatever the path is when cron runs it and call rake test_task.
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
The cron job definitely runs and which rake
works when run in the cron job.
回答1:
I fixed it by adding this to the script:
source ~/.rvm/scripts/rvm
来源:https://stackoverflow.com/questions/11571789/rake-task-with-cron-job