#!/bin/sh while [ 1 ] do Tag=`ps -ef|grep 'jar包名称'|grep -v grep|wc -l|awk '{printf $1" "}'` if [ $Tag = 0 ] then setsid /usr/lib/jvm/jdk-1.8/bin/java -jar jar包名称.jar fi done
setsid 后台运行
#!/bin/sh while [ 1 ] do Tag=`ps -ef|grep 'jar包名称'|grep -v grep|wc -l|awk '{printf $1" "}'` if [ $Tag = 0 ] then setsid /usr/lib/jvm/jdk-1.8/bin/java -jar jar包名称.jar fi done
setsid 后台运行