I have a Rails runner task that I want to run from cron
, but of course cron
runs as root
and so the environment is set up improperly to get RVM to work properly. I've tried a number of things and none have worked thus far. The crontab
entry is:
* 0 * * * root cd /home/deploy/rails_apps/supercharger/current/ && /usr/local/rvm/wrappers/ruby-1.9.3-p484/ruby bundle exec rails runner -e production "Charger.start"
Apologies for the super long command line. Anyhow, the error I'm getting from this is:
ruby: No such file or directory -- bundle (LoadError)
So ruby is being found in the RVM directory, but again, the environment is wrong.
I tried rvm alias delete [alias_name]
and it seemed to do something, but darn if I know where the wrapper it generated went. I looked in /usr/local/rvm/wrappers
and didn't see one with the name I had specified.
This seems like a common problem -- common enough that the whenever
gem exists. The runner command I'm using is so simple, it seemed like a slam dunk to just put this entry in the crontab
and go, but not so much...
Any help with this is appreciated.