Reputation: 48443
I have a Rails app, running on EC2 instance (Ubuntu distribution).
The thing is that the CRON tasks are never ran - which is the problem. They are working locally, but not on Amazon EC2 (probably because of incorrect paths to ruby etc - but unfortunately I am not very skilled in this area). How to run the CRON tasks with the Rails app (RVM)?
I am fighting the third day with this issue, but still cannot make it work, so I would be very grateful for every help.
Thank you
EDIT:
crontab -e
# Begin Whenever generated tasks for: /home/user_name/project/releases/201309301$
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /home/user_name/f$
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /home/user_name/f$
# End Whenever generated tasks for: /home/user_name/project/releases/20130930170$
schedule.rb
set :output, "/home/user_name/project/current/log/cron_log.log"
every 5.minutes do
puts "It's working !!!"
runner "User.grab_first_user!", :environment => 'production'
end
cron_log.log
: No such file or directory
....
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby/bin/bash: bundle: command not found
: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby/bin/bash: bundle: command not found
: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
: No such file or directory
/bin/bash: /usr/bin/some_great_command: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
/bin/bash: bundle: command not found
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: /usr/bin/some_great_command: No such file or directory
Upvotes: 0
Views: 442
Reputation: 10986
You should use absolute paths in cron. There is an option to define a PATH variable in cron which will be available to all your cron jobs. Look into cron documentation.
You can also use -l options with bash to invoke bash as alogin shell (meaning, make it set the environment based on your .bashrc etc.). See the sample command below
"/bin/bash -l -c 'cd /project/folder; RAILS_ENV=production /usr/bin/bundle exec rails runner ./script/monthly.rb >> ./cron_log 2>&1'"
Since you are using whenever
, have you defined job_type
in your schedule.rb
correctly? something like this...
job_type :rake, "cd :path && RAILS_ENV=:environment bundle exec rake :task --silent :output"
job_type :runner, "cd :path && RAILS_ENV=:environment bundle exec rails runner :task :output"
Also set the output so that all output from cron jobs is captured in a file for you to inspect
set :output, "/home/project/log/cron_log.log"
You should then be able to define tasks like this
every :day, :at => '12:01am' do
rake "ts:index"
end
every :month, :at => '05:10am' do
runner 'script/monthly_job.rb'
end
every :saturday, :at => "2:00am" do
command "/home/project/scripts/clean_stale_users.sh"
end
Update:
if using rvm
, follow these instructions for rvm integration with cron
Upvotes: 1
Reputation: 2858
The best solution for this I found is to use the 'whenever' gem, which allows you to define the task in your application and then if you use capistrano to deploy, it can automatically update the cron tasks on the server. If not using Capistrano you can use the command line on the server to generate the jobs.
Whenever: https://github.com/javan/whenever
Using Capistrano with Whenever is also described there.
Upvotes: 0