0
我想檢查每個小時如果delayed_job正在運行。對於這個我使用的cron用cron重新啓動delayed_job
29 * * * * /var/jenkins/jobs/Production/workspace/integration/check_runnig_jobs.sh
腳本如下。 當它自己執行時,它會啓動delayed_job。但是從cron執行時無法啓動,併發送郵件到/ var /郵件/ WWW的數據是:
19時19分01秒:開始檢查... 19時19分01秒:檢查delayed_job的 - 19:19:01:沒有運行,重新啓動... 在任何源中找不到i18n-0.6.0 嘗試運行bundle install
。 + 19:19:01:delayed_job正在運行
之後在正在運行的進程中找不到delayed_job。
你能幫助我們嗎?
劇本是
#!/bin/bash
# Check jobs that should be running on the production environment. This script might be croned or run by jenkins,
check_process() {
echo "$ts: checking $1"
[ "$1" = "" ] && return 0
[ `pgrep -fn $1` ] && return 1 || return 0
}
check_delayed_job() {
RAILS_ENV=production
export RAILS_ENV
name="delayed_job"
check_process $name
[ $? -eq 0 ] && echo "- $ts: not running, restarting..." && /var/jenkins/jobs/Production/workspace/script/delayed_job start
[ $? -eq 1 ] && echo "+ $ts: $name is RUNNING"
return 0
}
# timestamp
ts=`date +%T`
echo "$ts: begin checking..."
check_delayed_job
exit 0
你檢查過[ '每當'](https://github.com/javan/whenever)寶石? – backpackerhh
Delayed_job實際上運行良好,但是我從cron開始有問題,並且正在尋找一種方法來首先解決此問題。 – thebravoman