Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # 1. get the pid.
- FILE=pid.txt
- if [ -f $FILE ];
- then
- PID=`cat pid.txt`
- else
- PID=`ps -Af | awk -f getpid.awk`
- fi
- # 2. check if we have pid, then kill it appropriately.
- if [ "$PID" = "" ];
- then
- LEN=0;
- else
- LEN=`expr $PID : '.*'`
- fi
- #echo $LEN # TEST
- if [ "$LEN" -eq "0" ];
- then
- if [ "$1" != "force" ];
- then
- echo 'PID not found.'
- exit
- #else # TEST
- #echo 'got pid' # TEST
- fi
- else
- if [ "$1" = "force" ];
- then
- kill -9 $PID
- #echo "force quit" # TEST
- else
- kill $PID
- #echo "normal quit" # TEST
- fi
- fi
Add Comment
Please, Sign In to add comment