Answer the question
In order to leave comments, you need to log in
How to run rake with cron?
You need to run a cron job. I have a script
cd /path_to_project/
bundle exec rake name:action
If I just execute sh update.sh - everything is fine. And if I write the same command in cron, nothing happens
Answer the question
In order to leave comments, you need to log in
Probably because cd doesn't work for you .
stackoverflow.com/questions/255414/why-doesnt-cd-w...
stackoverflow.com/questions/874452/change-current-...
the problem is that cron has its own environment, for example, in PATH there is no path to either ruby or bundle, shell is different, etc. The correct way is to write your script so that all defaults are explicit - full paths, environment variable initialization, etc.
An easier way is to try to start your shell with the login option and execute the desired command in it. For example, it worked for me on Ubuntu like this
. I don’t presume to judge how “true” it is - perhaps knowledgeable people will comment ...
In general, for example
SHELL=/bin/sh
PATH=/home/deployer/.rbenv/bin:/home/deployer/.rbenv/bin:/home/deployer/.rbenv/bin:/home/deployer/.rbenv/bin:/home/deployer/.rbenv/bin:/home/deployer/.rbenv/shims:/home/deployer/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
cd /home/deployer/scum_cleaner/current && RAILS_ENV=production bundle exec rake kill:all_gays
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question