shell 实现监控程运行并自动重启

使用ps做进程查询

#!/bin/sh
while true
do
    procnum=`ps -ef|grep "testApp"|grep -v grep|wc -l`
    if [ $procnum -eq 0 ]; then
      /root/testApp &
    fi
      sleep 5
done

Tags:

Comments

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注