restart.sh 472 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. # 进程名
  3. process="timesheet"
  4. # 获取进程ID
  5. PID=$(ps -ef | grep $process | grep -v grep | awk '{print $2}')
  6. if [ -n "$PID" ]; then
  7. echo "$process is exist"
  8. if ps -p $PID >/dev/null; then
  9. echo "$process is runnig"
  10. else
  11. echo " $ process is not running"
  12. fi
  13. else
  14. echo "$process is not exist"
  15. fi
  16. echo $PID;
  17. # 暂停1秒
  18. sleep 1;
  19. kill -9 $PID;
  20. echo "$process is killed"
  21. ./startWorkTime.sh
  22. echo "restart timesheet success"