天天看点

shell监视进程是否存在

项目中发现magent进程莫名没有了,先写个shell脚本监控一下。有时间再查找原因。

#!/bin/sh

pid=`ps -ef | grep "magent" | grep "11113" | awk '{print $2}'`

if [ "$pid" == "" ];then

magent -u root -n 51200 -l 192.168.0.1 -p 11113 -s 192.168.0.2:11211 -s 192.168.0.3:11211 -b 192.168.0.1:11211

else

echo $pid > /dev/null

fi