8-18 897 views
编写shell脚本 deamon.sh
#! /bin/bash
while :
do
#grep -v grep 不显示grep本身
query=`ps -ef | grep 'python /usr/share/test/hello.py'|grep -v grep |awk '{print $2}'`
#res=进程ID
res=$query
if [ "$res" = "" ]
then
python /usr/share/test/hello.py &
echo "program exited, restart"
fi
sleep 10s
done
执行脚本
chmod +x deamon.sh
./deamon.sh &