进程监控脚本
gb@gb:~/Device-Mgr/Device-Mgr/bin$ vim run.sh
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:../lib;export LD_LIBRARY_PATH
HOME=/home/gb;export HOME
if [ $# -lt 1 ]
then
while(true)
do
if [ -x ${HOME}/Device-Mgr/Device-Mgr/bin/Device-Mgr ]
then
prog=$(ps -ef | grep Device-Mgr |grep -v grep | awk '{print $8}' | cut -f 7 -d"/" | sort | tail -1)
if [ "${prog}" != "Device-Mgr" ]
then
echo "Start Device-Mgr ..."
nohup ${HOME}/Device-Mgr/Device-Mgr/bin/Device-Mgr &
fi
else
echo "${HOME}/Device-Mgr/Device-Mgr/bin/Device-Mgr is not executed"
fi
sleep 5
done
fi
gb@gb:~/Device-Mgr/Device-Mgr/bin$ ./run.sh
Start Device-Mgr ...
nohup: appending output to 'nohup.out'
^C
gb@gb:~/Device-Mgr/Device-Mgr/bin$ ps -ef |grep Device-Mgr
gb 2574 1 0 02:34 pts/0 00:00:00 /home/gb/Device-Mgr/Device-Mgr/bin/Device-Mgr
gb 2625 1755 0 02:34 pts/0 00:00:00 grep --color=auto Device-Mgr
gb@gb:~/Device-Mgr/Device-Mgr/bin$