-
-
Save HuanMeng0/5381928e419b8495b17bd3acbc3ed1e2 to your computer and use it in GitHub Desktop.
持续监控一个程序是否运行
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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