【Shell Script】杀死某个程序并重新启动

2021-04-27  本文已影响0人  Lyudmilalala
#!/bin/sh

#cur location is /var/lib/jenkins/workspace/{project_name}
echo "[INFO] environment = $environment, jar_name = $jar_name"
jar_path="target/"$jar_name
mvn clean install -Dmaven.test.skip=true -P $environment
echo "[INFO] Build finished."
# if jar is currently running, kill the old process
pid=`ps -ef | grep ${jar_name} | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
echo "[INOF] Kill old server."
kill -15 $pid
fi
# start the new process
nohup java -jar $jar_path
上一篇下一篇

猜你喜欢

热点阅读