java 的守护进程脚本
#!/bin/sh while [ 1 ] do Tag=`ps -ef|grep 'jar包名称'|grep -v grep|wc -l|awk '{printf $1"\n"}'` 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"\n"}'` if [ $Tag = 0 ] then setsid /usr/lib/jvm/jdk-1.8/bin/java -jar jar包名称.jar fi done
setsid 后台运行