Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- BASE_HOME=$(dirname $(readlink -f "$0"))
- PID=${BASE_HOME}/.pid
- status(){
- echo "==========status======="
- status=`ps -p $$`
- }
- start() {
- echo "==========start==========="
- }
- stop() {
- echo "===========stop============"
- pid=$$
- kill_cmd="pstree -p $pid | awk -F \"[()]\" '{for(i=0;i<=NF;i++)if(\$i~/[0-9]+/)print \$i}' |"'grep -v -E "\[|\(|\)|\]"|xargs kill -9'
- eval ${kill_cmd}
- }
- restart() {
- stop;
- echo "sleeping.........";
- sleep 3;
- start;
- }
- case "$1" in
- 'start')
- start
- ;;
- 'stop')
- stop
- ;;
- 'status')
- status
- ;;
- 'restart')
- restart
- ;;
- *)
- echo "usage: $0 {start|stop|restart|status}"
- exit 1
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement