简体   繁体   English

Amazon EC2不了解CRON作业

[英]Amazon EC2 doesn't know about CRON jobs

I have a Rails app, running on EC2 instance (Ubuntu distribution). 我有一个在EC2实例(Ubuntu发行版)上运行的Rails应用程序。

The thing is that the CRON tasks are never ran - which is the problem. 问题是CRON任务永远不会运行-这就是问题所在。 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). 他们在本地工作,但不在Amazon EC2上工作(可能是由于通往红宝石的路径不正确等原因-不幸的是,我在这方面不是很熟练)。 How to run the CRON tasks with the Rails app (RVM)? 如何使用Rails应用程序(RVM)运行CRON任务?

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 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 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 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

You should use absolute paths in cron. 您应该在cron中使用绝对路径。 There is an option to define a PATH variable in cron which will be available to all your cron jobs. 有一个选项可以在cron中定义PATH变量,该变量将可用于所有cron作业。 Look into cron documentation. 查看cron文档。

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.). 您还可以将-l选项与bash一起使用,以将bash作为登录外壳程序调用(意味着,使其根据您的.bashrc等设置环境)。 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? 由于您在whenever都使用,是否已在schedule.rb正确定义了job_type 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 还要设置输出,以便将cron作业的所有输出捕获到一个文件中,以供您检查

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 如果使用rvm ,请按照以下说明将rvm与cron集成

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. 我发现的最佳解决方案是使用“无论何时” gem,它使您可以在应用程序中定义任务,然后,如果您使用capistrano进行部署,它可以自动更新服务器上的cron任务。 If not using Capistrano you can use the command line on the server to generate the jobs. 如果不使用Capistrano,则可以使用服务器上的命令行来生成作业。

Whenever: https://github.com/javan/whenever 每当: https : //github.com/javan/whenever

Using Capistrano with Whenever is also described there. 此处还介绍了将Capistrano与“无论何时使用”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM