shell腳本強制進程重啓

while :
do
echo "Current DIR is " $PWD
stillRunning=$(ps -ef |grep "$PWD/a.out" |grep -v "grep")
if [ "$stillRunning" ] ; then
echo "TWS service was already started by another way"
echo "Kill it and then startup by this shell, other wise this shell will loop out this message annoyingly"
kill -9 $pidof $PWD/a.out
else
echo "TWS service was not started"
echo "Starting service ..."
$PWD/a.out
echo "TWS service was exited!"
fi
sleep 10
done

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章