【问题标题】:Duplicate process in cron job using Whenever gem for Rails在 cron 作业中使用 When gem for Rails 重复进程
【发布时间】:2015-02-05 00:22:46
【问题描述】:

使用 Rails 3.2.21,无论何时 gem。这是我的 crontab 列表:

Begin Whenever generated tasks for: abc 0 * * * * /bin/bash -l -c 'cd /home/deployer/abc/releases/20141201171336 && RAILS_ENV=production bundle exec rake backup:perform --silent'

这是运行计划作业时的输出:

deployer@localhost:~$ ps aux | grep rake deployer 25593 0.0 0.0 4448 764 ? Ss 12:00 0:00 /bin/sh -c /bin/bash -l -c 'cd /home/deployer/abc/releases/20141201171336 && RAILS_ENV=production bundle exec rake backup:perform --silent' deployer 25594 0.0 0.1 12436 3040 ? S 12:00 0:00 /bin/bash -l -c cd /home/deployer/abc/releases/20141201171336 && RAILS_ENV=production bundle exec rake backup:perform --silent deployer 25631 69.2 4.4 409680 90072 ? Sl 12:00 0:06 ruby /home/deployer/abc/ shared/bundle/ruby/1.9.1/bin/rake backup:perform --silent deployer 25704 0.0 0.0 11720 2012 pts/0 S+ 12:00 0:00 grep --color=auto rake

请注意,前 2 个进程实际上是相似的进程。他们是否同时运行 2 个相同的作业?我该如何预防?

【问题讨论】:

    标签: ruby-on-rails linux cron


    【解决方案1】:

    检查您的 scheduled.rb 是否有重复条目,如果发现则删除并部署。
    如果 schedule.rb 中没有重复条目,则需要从 cron 选项卡中删除/注释它。
    要删除或评论 cron 中的作业,请查看 https://help.1and1.com/hosting-c37630/scripts-and-programming-languages-c85099/cron-jobs-c37727/delete-a-cron-job-a757264.htmlhttp://www.esrl.noaa.gov/gmd/dv/hats/cats/stations/qnxman/crontab.html

    【讨论】:

    • 实际原因可能是没有在 deploy.rb 中提供whenever_identifierapplication 设置
    • 我遇到了这个问题。然后我发现,在 deploy.rb 文件中,这个“每当”动作被调用了两次。
    【解决方案2】:
    部署者 25593 0.0 0.0 4448 764 ? SS 12:00 0:00 /bin/sh -c /bin/bash … 部署者 25594 0.0 0.1 12436 3040 ? S 12:00 0:00 /bin/bash …

    请注意,前 2 个进程实际上是相似的进程。他们是否同时运行 2 个相同的作业?

    不,他们不是。第一个是/bin/sh,它启动了第二个,crontab 命令/bin/bash …。很可能/bin/sh 只是在等待/bin/bash 的终止,并且在/bin/bash … 完成执行之前不再运行;您可以使用 e 验证这一点。 G。 strace -p 25593.

    【讨论】:

      猜你喜欢
      • 2016-03-01
      • 2014-07-15
      • 2013-08-20
      • 2019-10-19
      • 2016-04-22
      • 1970-01-01
      • 1970-01-01
      • 2016-05-02
      • 1970-01-01
      相关资源
      最近更新 更多