概述
# 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 脚本监控java进程所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复