# ps -ef|grep tomcat_community|grep -v 'grep'|awk '{print $2}'
# 这里的-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
最后
以上就是虚心柠檬最近收集整理的关于Shell 脚本监控java进程的全部内容,更多相关Shell内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复