restart.sh 446 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. echo "begin restart..."
  3. cd ../
  4. PROCESS=`pwd | xargs -i basename {}`
  5. COUNT=`ps -ef|grep "\./$PROCESS"|grep -v grep|wc -l`
  6. if [ $COUNT -lt 1 ]; then
  7. echo "process $PROCESS not exist!"
  8. fi
  9. PID=`ps -ef | grep "$PROCESS" | grep -v grep | grep -v awk | awk '{print $2}'`
  10. echo "kill -HUP ${PID}"
  11. kill -HUP ${PID}
  12. if [ $? != "0" ]; then
  13. echo "Restart $PROCESS Failed."
  14. exit 1
  15. else
  16. echo "Restart $PROCESS OK."
  17. exit 0
  18. fi