linux apache 自动监护脚本
1 首先安装curl
yum install curl
2 编写shell
vi restart_apache.sh
写入一下内容
#!/bin/bash
URL="http://127.0.0.1/"
curlit()
{
curl --connect-timeout 35 --max-time 40 --head --silent "$URL" | grep '200'
}
doit()
{
if ! curlit; then
sleep 20
top -n 1 -b >> /var/log/restart_log/apache.log
/etc/init.d/httpd stop
sleep 2
/etc/init.d/httpd start > /dev/null
echo $(date) "Apache Restart" >> /var/log/restart_log/re_apache.log
sleep 30
if ! curlit; then
echo $(date) "Failed! Now Reboot Computer!" >> /var/log/restart_log/rebot_apache.log
reboot
fi
sleep 180
fi
}
sleep 300
while true; do
doit > /dev/null
sleep 10
done
3 把restart_apache.sh 加入到定时计划任务
crontab -e
写入以下内容
*/1 * * * * /home/restart_apache.sh //一分钟执行一次
crontab -l 查看 是否加入成功
4 chmod +x restart_apache.sh 表示可以执行
/sbin/service crond stop
5 测试 把apache停止 然后测试 过一会看看apache是否已经自动启动
http://www.cnitblog.com/201/archive/2010/06/17/66805.html
http://blog.csdn.net/xifeijian/article/details/8703903
http://www.bootf.com/599.html
linux apache 自动监护脚本的更多相关文章
- linux LNMP自动安装脚本
#!/bin/bashsoft_dir="/home/soft"config_dir="/home/config"httpd="httpd-2.0.5 ...
- linux 项目自动部署脚本
1.使用maven获取源码部署,并可替换配置文件(金融数据分析平台) #!/bin/bash#设置变量cd /home#停止tomcatecho "开始停止tomcat..." p ...
- Linux Shell 自动备份脚本
写一个使用shell脚本增量备份系统文件,顺便复习一下shell脚本相关的命令,这个脚本可以根据自己的需求来备份不同的文件或者文件夹,进行完整备份和增量备份. 参考的网址:http://blog.51 ...
- Linux Expect自动交互脚本
https://likegeeks.com/expect-command/ In the previous post, we talked about writing practical shell ...
- Oracle自动备份脚本(网上找到的资料)
废话不多说了,直接给大家贴代码了,具体代码如下所示: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ...
- LINUX 自动备份脚本文件
首先我在/root/backup 目录下建立一个文件夹, #mkdir /root/backup/mysqlbackup 以后在每天五点钟,就会有一个文件保存在这里. 接着新建文件 #vim /roo ...
- 使用php作linux自动执行脚本
使用php作linux自动执行脚本 [来源] 达内 [编辑] 达内 [时间]2013-03-21 在作社区时, 时常需要统计上线人数等数据. 一般做法是, 把这段代码放在用户 login或者 ...
- linux - 怎么自动填写有交互的shell脚本 - SegmentFault
linux - 怎么自动填写有交互的shell脚本 - SegmentFault TCL/Expect交互式自动化测试概要 - - ITeye技术网站 expect是一种基于TCL,能与交互式程序进行 ...
- Linux oracle数据库自动备份自动压缩脚本代码
Linux oracle数据库备份完成后可以自动压缩脚本代码. 复制代码代码如下: #!/bin/bash #backup.sh #edit: www.jbxue.com ##系统名称 sysname ...
随机推荐
- Python基础学习笔记(一)入门
参考资料: 1. <Python基础教程> 2. http://www.runoob.com/python/python-chinese-encoding.html 3. http://w ...
- 拓扑排序--UVa10305
题目 Output: standard output Time Limit: 1 second Memory Limit: 32 MB John has n tasks to do. Unfortun ...
- iOS - Threads 多线程
1.Threads 1.1 进程 进程是指在系统中正在运行的一个应用程序.每个进程之间是独立的,每个进程均运行在其专用且受保护的内存空间内. 比如同时打开 QQ.Xcode,系统就会分别启动两个进程. ...
- html一般标签、常用标签、表格
body的属性: bgcolor 页面背景色 text 文字颜色 topmargin 上边距 leftmargi ...
- 路由器WAN端与LAN端的区别
路由器WAN端与LAN端的区别 WAN的全称为Wide Area Network,即广域网.而LAN的全称为Local Area Network,即局域网.WAN口主要用于连接外部网络,如ADSL.D ...
- tomcat字符,文档,数据库配置
修改tomcat目录下conf目录下的server.xml tomcat容器的解码配置 URIEncoding="UTF-8" <Connector port="8 ...
- Java 默认/缺省 server 还是 client 模式
不多说,复制官方文档,适用于 Java 5 6 7 Architecture OS Default client VM if server-class, server VM; otherwise, c ...
- cocoapods ,错误大全
出现这种警告 Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not us ...
- 可持久化Trie & 可持久化平衡树 专题练习
[xsy1629]可持久化序列 - 可持久化平衡树 http://www.cnblogs.com/Sdchr/p/6258827.html [bzoj4260]REBXOR - Trie 事实上只是一 ...
- 如何通过ildasm/ilasm修改assembly的IL代码
原文地址:http://kb.cnblogs.com/page/101162/ 这段时间为跟踪一个Bug而焦头烂额,最后发现是Framework的问题,这让人多少有些绝望.所以到微软论坛提了个帖子,希 ...