假设Jar包名称为 ikun666.jar
ps -aux | grep java
kill -9 你jar包的进程号
nohup java -jar ikun666.jar >/dev/null 2>&1 &
ps aux | grep java | grep ikun666 | awk '{print $2}'
pgrep -f "java.*ikun666"
#!/bin/bash
if pgrep -f "java.*ikun666" >/dev/null; then
echo "kill ikun666 process"
pkill -f "java.*ikun666"
else
echo "ikun666 process is not running."
fi
echo "start ikun666 process"
nohup java -jar /opt/ikun666.jar >/dev/null 2>&1 &