簡體   English   中英

每當CRON選項卡在Amazon EC2上不起作用時

[英]Whenever CRON tab doesn't work on Amazon EC2

我正在嘗試使用Whenever 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 ,該文件未編輯。

怎么了 每2分鍾CRON作業不會在EC2上運行一次嗎?

可以嘗試的一些選項:

1)登錄服務器並運行:

bundle exec whenever --update-crontab

並檢查您的crontab。

2)您不需要設置after回調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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM