linux 根据文件名 一键kill文件运行进程id
#!/bin/bash
echo "************ 查找进程 **************"
pid=`ps -ef | grep "demo-0.0.1-SNAPSHOT.jar" | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]; then
echo $pid Manager
kill -9 $pid
if [ "$?" -eq 0 ]; then
echo "kill success"
else
echo "kill failed"
fi
echo "************ 杀掉进程 **************"
fi
nohup java -jar /admin/webapps/demo-0.0.1-SNAPSHOT.jar > nohup.log 2>&1 &
echo "************ 启动成功 **************"
exit 0

浙公网安备 33010602011771号