Created
November 5, 2012 01:24
-
-
Save kany/4014717 to your computer and use it in GitHub Desktop.
ubuntu,rvm,crontab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.wyliethomas.com/blog/2011/08/24/rvm-rake-and-cron-on-ubuntu/ | |
RVM, Rake and Cron on Ubuntu | |
by admin on August 24th, 2011 | |
Tennnngh! I read countless blog posts, tried numerous approaches that I found and rebuilt the server more than a couple times. And finally I found what the missing piece was for getting a rake command to run in cron with rvm. | |
Most of the results I found (on stackoverflow) flagged the solution as adding the path to your rvm in your line item in crontab. Something like /home/username/.rvm/gems/rake my_awesome_task… etc. I tried every variation of that I could think of and got the same results. | |
I dont use cron every day so this was a revelation to me. I found out that you can set variables, environment variables in your crontab file. | |
So the solution was very simple. Edit the crontab like this. | |
crontab -e | |
Then at the top of the file (mine is the first line) | |
SHELL = /home/wylie/.rvm/bin/rvm-shell | |
Then my commands: | |
* 4 * * * /bin/bash -l -c ‘cd /path/to/app && RAILS_ENV=production rake mytask –silent’ | |
Done. | |
Hope that saves someone some time. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment