擅长:python、mysql、java
<p>将cronjob设置为每5分钟运行一次,以监视任务是否正在运行。在</p>
<p>下面是一个在bash中可以工作的示例</p>
<pre><code># assuming your app is called temp_monitor.py
cmd="ps ux | grep temp_monitor.py | grep -v grep"
start="python temp_monitor.py"
# run the command to check
eval "$cmd"
# did the previous command return a non-zero exit code?
if [ $? -ne 0 ]; then
$start
fi
</code></pre>