Skip to content

Instantly share code, notes, and snippets.

@HuanMeng0
Created July 20, 2016 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HuanMeng0/5381928e419b8495b17bd3acbc3ed1e2 to your computer and use it in GitHub Desktop.
Save HuanMeng0/5381928e419b8495b17bd3acbc3ed1e2 to your computer and use it in GitHub Desktop.
持续监控一个程序是否运行
#!/bin/bash
while [ 1 ]
do
procID=`pgrep APPNAME`
if [ "" == "$procID" ];
then
nowdate=`date '+%Y-%m-%d %H:%M:%S'`
echo "${nowdate}" >> /root/exitlog
exit 0
fi
usleep 1000
done &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment