手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >Linux Shell脚本实现检测tomcat
Linux Shell脚本实现检测tomcat
摘要:LinuxShell脚本检测tomcat并自动重启后台运行命令shxxx.sh&查看后台任务:jobs召唤到前台:fgjobs编号可以删掉w...

Linux Shell脚本检测tomcat并自动重启

后台运行命令 sh xxx.sh &

查看后台任务:jobs

召唤到前台:fg jobs编号

可以删掉while循环的代码放到crontab里面定时执行,可以将脚本直接后台运行,

#!/bin/bash while [ true ] do url="http://www.jb51.net/"; httpOK=`curl --connect-timeout 10 -m 60 --head --silent $url | awk 'NR==1{print $2}'`; if [ $httpOK == "200" ];then tomcat6=`ps -ef | grep tomcat | awk 'NR==1{print $1" "$2;}'`; user=`echo $tomcat6 | awk 'NR==1{print $1}'`; pid=`echo $tomcat6 | awk 'NR==1{print $2}'`; if [ $user != "tomcat" ]; then service tomcat6 start; else kill -9 $pid;sleep 5s;service tomcat6 start;service tomcat6 start;service tomcat6 status; fi; fi; sleep 5m; done;

以上所述就是本文的全部内容了,希望大家能够喜欢。

【Linux Shell脚本实现检测tomcat】相关文章:

Shell脚本实现自动检测修改最快的Ubuntu软件源

Linux命令行和shell脚本编程宝典 Richard Blum

Shell脚本实现检测某ip网络畅通情况(含短信报警功能)

Shell脚本注释写法

Linux Shell简介

Shell脚本实现自动输入密码登录服务器

Shell脚本实现监控rsync数据是否传输完

Shell脚本避免重复执行的方法

Linux内核链表实现过程

Shell脚本实现检测进程是否正在运行

精品推荐
分类导航