1. 程式人生 > >Linux-- 簡單的程式守護指令碼,程式異常退出後自動重啟

Linux-- 簡單的程式守護指令碼,程式異常退出後自動重啟

#!/bin/sh

while true

do

ps -ef | grep "test(程式名)" | grep -v "grep"

if ["$?" -eq 0]

then

./test

echo "wath process has been restarted! "

else

echo "watch process already started ! "

fi

sleep 1

done