在 cron 作业中使用 Ever gem for Rails 复制进程



使用 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 个相同的作业?我该如何防止这种情况?

部署程序 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/垃圾桶/撇...

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

不,他们不是。第一个是启动第二个的/bin/sh,crontab 命令/bin/bash … 。最有可能的是/bin/sh只是等待/bin/bash终止,并且在/bin/bash …完成执行之前不再运行;您可以使用例如 strace -p 25593 .

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

相关内容

最新更新