- # 这里的-f参数判断$myFile是否存在
- pidfile=java.pid
- if [ ! -f "$pidfile" ]; then
- touch ${pidfile};
- echo "$pidfile new create finish";
- fi
- # $! 后台运行的最后一个进程的进程ID号
- trap "" 1 2 3 24
- while true
- do
- if [ -z $(cat $pidfile) ] ; then
- echo "$pidfile is empty";
- fi;
- pid=$(ps -ef|grep java|grep lf-lfzb.jar|grep $(cat $pidfile)|awk '{print $2}')
- echo "current mode lf-lfzb.jar java pid value is " $pid;
- if [ "$pid" != $(cat $pidfile) ] ; then
- #./shutdown.sh
- /opt/jdk/bin/java -jar lf-lfzb.jar -Dfile.encoding=UTF-8 >>/dev/null & echo $! > ${pidfile}
- fi
- sleep 5
- #break
- done