以java程序为例:
停止程序
#!/bin/bash
echo "the stop ....."
program_name=test.jar
count=`ps -ef | grep $program_name | grep -v grep |wc -l`
if [ $count -gt 0 ];then
pid=`ps -ef | grep $program_name | grep -v grep | awk '{print $2}'`
echo "pid = $pid"
kill -9 $pid
echo "program $program_name has stoped."
else
echo "program $program_name not running, no need to stop."
fi
echo "success stop ....."
启动程序
#!/bin/bash echo "the start ....." nohup java -jar test.jar > /dev/null 2>&1 & echo started echo "sucess start....."



