Guest User

Untitled

a guest
May 21st, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # 1. get the pid.
  4. FILE=pid.txt
  5. if [ -f $FILE ];
  6. then
  7. PID=`cat pid.txt`
  8. else
  9. PID=`ps -Af | awk -f getpid.awk`
  10. fi
  11.  
  12. # 2. check if we have pid, then kill it appropriately.
  13. if [ "$PID" = "" ];
  14. then
  15. LEN=0;
  16. else
  17. LEN=`expr $PID : '.*'`
  18. fi
  19. #echo $LEN # TEST
  20. if [ "$LEN" -eq "0" ];
  21. then
  22. if [ "$1" != "force" ];
  23. then
  24. echo 'PID not found.'
  25. exit
  26. #else # TEST
  27. #echo 'got pid' # TEST
  28. fi
  29. else
  30. if [ "$1" = "force" ];
  31. then
  32. kill -9 $PID
  33. #echo "force quit" # TEST
  34. else
  35. kill $PID
  36. #echo "normal quit" # TEST
  37. fi
  38. fi
Add Comment
Please, Sign In to add comment