#filename:variable#pname配置J2SE程序入口类名,即包含启动main方法的类pname=com.*.*.*
#!/bin/sh#filename:run.shsource variable#下面请填写自己的classpathjava -cp lib/*:. $pname
#!/bin/sh #filename:startup.sh source variable pid=`ps -ef|grep $pname|grep -v grep|awk '{print $2}'` if [ "X$pid" = "X" ] then ./run.sh : run $* & sleep 1 pid=`ps -ef|grep $pname|grep -v grep|awk '{print $2}'` echo $pid > run.pid echo "START UP [$pname]" else echo "THE PROCESS IS ALREADY RUNNING!!!" ps -ef|grep $pid|grep -v grep fi
#!/bin/sh #filename:shutdown.sh source variable if test -f run.pid; then kill -1 `cat < run.pid` rm run.pid echo "SHUTDOWN [$pname]" else pid=`ps -ef|grep $pname|grep -v grep|awk '{print $2}'` if [ "X$pid" = "X" ] then echo "THERE IS NO RUNNING PROCESS. [$pname]" else ps -ef|grep $pname|grep -v grep|awk '{print $2}'|xargs kill -1 echo "THERE IS RUNNING PROCESS NAME [$pname] BUT NOT SURE TO SHUTDOWN." ps -ef|grep $pid|grep -v grep fi fi
以上四个文件请放在同一目录下