1.启动进程
##!/bin/bash
APP_NAME=demo.jar
PID='ps -ef |grep "APP_NAME" | grep -v "grep" | awk '{print $2}''
if [-z $PID ]; then
echo "process id is empty,process is not existed..."
else
echo $PID
for id in $PID
do
echo "kill Pid : $id"
done
fi
echo "stop success...,begin to restart"
nohup java -jar $APP_NAME > /dev/null 2>&1 &
sleep 1
PID='ps -ef |grep "APP_NAME" | grep -v "grep" | awk '{print $2}''
if [-z $PID];then
echo "peocess restart failure"
else
echo "process restart success:$PID"
fi
2.停止进程
(1)
ps aux|grep demo.jar|grep -v "grep"|awk '{print $2}' |xargs kill -9
(2)
#!/bin/bash
appserver=redis-server
pid=`ps -ef|grep ${appserver} |grep -v grep|awk '{print $2}'`
if ["$pid" != ""] then
echo "kill ${appserver}: $pid"
kill -9 $pid
else
echo "${appserver} is not running."
fi