0

我有一个 Rails 应用程序,在 EC2 实例(Ubuntu 发行版)上运行。

问题是 CRON 任务从未运行过——这就是问题所在。他们在本地工作,但不在 Amazon EC2 上(可能是因为 ruby​​ 的路径不正确等 - 但不幸的是我在这方面不是很熟练)。如何使用 Rails 应用程序 (RVM) 运行 CRON 任务?

我正在解决这个问题的第三天,但仍然无法使其正常工作,所以我将非常感谢每一个帮助。

谢谢

编辑:

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$

日程安排.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
4

2 回答 2

1

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

于 2013-10-01T14:12:16.420 回答
0

我发现最好的解决方案是使用'whenever' gem,它允许您在应用程序中定义任务,然后如果您使用 capistrano 进行部署,它可以自动更新服务器上的 cron 任务。如果不使用 Capistrano,您可以使用服务器上的命令行来生成作业。

无论何时: https ://github.com/javan/whenever

那里还描述了将 Capistrano 与任何时候一起使用。

于 2013-10-01T13:51:24.913 回答