linux 简易启动脚本

#/bin/bash

pid=`ps -ef | grep 'testDemo' | grep -v grep |awk '{print $2}'`

case $1 in
        start)
                nohup java -j testDemo.jar > log.txt 2>&1 &
                echo "testDemo is RUNNING"
                ;;
        stop)
                echo "$pid is killed"
                kill -9 $pid
                ;;
        restart)
                stop;
                start;
                ;;
        status)
                if [ ! $pid ]; then
                        echo "testDemo NOT run"
                else
                        echo "testDemo is RUNNING, pid-- $pid"
                fi
                ;;
        *)
                echo "usage: $0 {start|stop|restart|status}"
                exit -1
                ;;
esac

可以参考这个demo

posted @ 2017-07-10 16:08  whendream  阅读(271)  评论(1编辑  收藏  举报