Answer the question
In order to leave comments, you need to log in
Why doesn't Bundle exec rake work in Cron?
There is a server on Ubuntu 13.10.
There is a project on Ruby On Rails and several rake tasks that work on cron every 3 minutes.
There is a gem Whenever which syntax is like
every 3.minutes do
rake 'update_balance'
end
Converts to string in Crontab file0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /bin/bash -l -c 'cd /var/fruby/releases/20140513091404 && RAILS_ENV=production bundle exec rake update_balance --silent'
So, this script, being run manually (with the same line as in Cron), works great and makes certain entries in the database. May 13 13:06:01 sandbox2 CRON[9656]: (root) CMD (/bin/bash -l -c 'cd /var/fruby/releases/20140513091404 && RAILS_ENV=production bundle exec rake update_balance --silent')
May 13 13:06:01 sandbox2 CRON[9655]: (CRON) info (No MTA installed, discarding output)
May 13 13:09:01 sandbox2 CRON[9789]: (root) CMD (/bin/bash -l -c 'cd /var/fruby/releases/20140513091404 && RAILS_ENV=production bundle exec rake update_balance --silent')
BUT, at the same time, the script definitely does not work out, i.e. I don't see any results from running it, and when I try to append &>/tmp/mycommand.log to the Cron task , the file is simply cleared each time the next cron task is run, although when run manually, the output will be something like this:2014-05-13T11:11:25Z 10292 TID-2asbo INFO: Sidekiq client with redis options {:url=>"redis://127.0.0.1"}
Sent task for updating 2 users
I would be grateful for any tips on where to dig and what to look for? Answer the question
In order to leave comments, you need to log in
This question on Stackoverflow helped me solve my problem:
stackoverflow.com/questions/2388087/how-to-get-cro...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question