您现在的位置是:网站首页> 编程资料编程资料
自动重启服务的shell脚本代码_linux shell_
2023-05-26
409人已围观
简介 自动重启服务的shell脚本代码_linux shell_
复制代码 代码如下:
#!/bin/bash
if [ ! -f /tmp/down_count ];then
echo "0" > /tmp/down_count
fi
curl -I tomcat-host -o "/tmp/status" >/dev/null 2>&1
code=`awk 'NR==1 {print $2}' /tmp/status`
if [ "$[code]" -ge 500 ];then
down=`expr $(cat /tmp/down_count) + 1`
echo "$down" > /tmp/down_count
if [ "$down" -gt 3 ];then
if [ ! -f "/tmp/restart_count" ];then
echo "0" > /tmp/restart_count
fi
restart_count=`expr $(cat /tmp/restart_count) + 1`
echo "$restart_count" > /tmp/restart_count
if [ "$restart_count" -le 2 ];then
echo "tomcat down at `date`" >> /tmp/down_info
/etc/init.d/tomcat6 restart
fi
fi
else
echo "0" > /tmp/down_count
echo "0" > /tmp/restart_count
fi
脚本实现了,当检测网页状态码大于等于500连续出现3次数,自动重启tomcat6,且只连续重启两次。
您可能感兴趣的文章:
- 分享个简易版Linux服务器初始化Shell脚本
- Linux shell脚本基础学习详细介绍(完整版)
- 利用Shell脚本实现远程MySQL自动查询
- linux服务器安全加固shell脚本代码
- 用shell脚本实现自动切换内网和外网实现高可用
- 如何调试Linux shell脚本
- linux下监视进程 崩溃挂掉后自动重启的shell脚本
- linux shell脚本基础知识学习
- 学习shell脚本之前的基础知识[图文]
- linux中mysql备份shell脚本代码
- Linux下使用Shell脚本实现ftp的自动上传下载的代码小结
- 获取两个日期间隔时间的shell脚本代码
- 判断文件是否存在的shell脚本代码
- kill特定进程的shell脚本代码
- 查找目录下同名但不同后缀名文件的shell脚本代码
- 在指定目录查找指定后缀文件的shell脚本代码
- 统计网卡流量的两段shell脚本(使用ifconfig)
- shell脚本作为保证PHP脚本不挂掉的守护进程实例分享
相关内容
- linux shell中的比较符号与特殊符号介绍_linux shell_
- Linux Shell简介_linux shell_
- 使用scp获取远程linux服务器上的文件 linux远程拷贝文件_linux shell_
- linux命令详解之挂载光驱的方法_linux shell_
- linux命令详解之useradd命令使用方法_linux shell_
- linux命令详解之chkconfig命令使用方法_linux shell_
- linux查看所有用户和查看用户组的方法(修改用户组)_linux shell_
- linux系统下dd命令的使用方法_linux shell_
- linux命令切换目录的使用方法_linux shell_
- linux查看目录的四种方法(ls只显示目录)_linux shell_
