Created
December 15, 2011 21:57
-
-
Save gonzedge/1483093 to your computer and use it in GitHub Desktop.
Using RVM within a cron job
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
0 */12 * * * /bin/bash -l -c 'source "$HOME/.rvm/scripts/rvm" && rvm use 1.9.2 && rvm gemset use records_app && cd /path/to/the/records_app/ && rake check_expired_records' |
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
0 */12 * * * cd /path/to/the/records_app/ && rake check_expired_records |
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
0 */12 * * * rvm use 1.9.2 && rvm gemset use records_app cd /path/to/the/records_app/ && rake check_expired_records |
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
0 */12 * * * PATH=$PATH:$HOME/.rvm/bin && rvm use 1.9.2 && rvm gemset use records_app && cd /path/to/the/records_app/ && rake check_expired_records |
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
0 */12 * * * PATH=$PATH:$HOME/.rvm/bin:$HOME/.rvm/gems/ruby-1.9.2-p290@records_app/bin && rvm use 1.9.2 && cd /path/to/the/records_app/ && rake check_expired_records |
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
error (grandchild #4993 failed with exit status 127) |
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
task :check_expired_records do | |
Record.where('expired = ? AND expires_at < ?', false, Time.now).each do |record| | |
# send some emails | |
# ... | |
# take some other actions | |
# ... | |
record.expired = true | |
record.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment