0

我正在尝试使用When gem 在 Amazon EC2 上设置 CRON 作业。在schedule.rb以下:

 set :output, "/home/my_deploy_name/my_deploy_name/current/log/cron_log.log"

 every 2.minutes do
   puts "It's working !!!"
 end

deploy.rb这个:

...
set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
after 'deploy:create_symlink', 'whenever:update_crontab'
after 'deploy:rollback', 'whenever:update_crontab'

当我将此代码部署到 EC2 并检查crontab -l时,输出为:

no crontab for ubuntu

当我运行时crontab -e,该文件没有被编辑。

这里有什么问题?什么 CRON 作业不是每 2 分钟在 EC2 上运行一次?

4

1 回答 1

0

一些尝试的选项:

1)登录服务器并运行:

bundle exec whenever --update-crontab

并检查你的 crontab。

2)您不需要设置beforeafter回调。capistrano 食谱为您做到了:

https://github.com/javan/whenever/blob/master/lib/whenever/capistrano.rb

Capistrano::Configuration.instance(:must_exist).load do
  # Write the new cron jobs near the end.
  before "deploy:finalize_update", "whenever:update_crontab"
  # If anything goes wrong, undo.
  after "deploy:rollback", "whenever:update_crontab"
end
于 2013-09-30T12:58:12.270 回答