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 ...
随机推荐
- 动态CSS--less
忙了很久终于有时间来写点东西了,不知道大家有没有发现,我们在写CSS的时候总是在重复很多代码,一个相同的属性值往往要重复N次,以前我就经常想有没有什么办法能让我们不用一直重复的font-size啊co ...
- eclipse查看jdk源码,及反编译查看
jdk中的包: dt.jar是关于运行环境的类库,主要是swing的包 tools.jar是关于一些工具的类库 rt.jar包含了jdk的基础类库,也就是你在java doc里面看到的所有的类的cla ...
- eclipse 安装git
1.安装Git 首先安装Git.这里只讲Windows环境下安装Git方法. 从Git下载git的Windows安装文件,一路Next到选择安装组件这一步: 选上Git Bash Here这一项,这样 ...
- [转]ubuntu下安装程序的三种方法
出处:http://www.cnblogs.com/xwdreamer/p/3623454.html 引言 在ubuntu当中,安装应用程序我所知道的有三种方法,分别是apt-get,dpkg安装de ...
- U盘安装XP_sp3
1. 用的是老毛桃的 U盘制作工具(百度云OsSkill --> 全部文件 --> 软件安装包 --> 老毛桃 --> Install_LMT_v9_2__Win_x86.ex ...
- iOS企业版打包(转载)
转自 http://www.cnblogs.com/shenlaiyaoshi/p/5472474.html 神来钥匙-陈诗友 iOS 企业版 打包 使用 iOS 企业版的证书发布应用可以跳过 A ...
- meta标签清理缓存
如果需要在html页面上设置不缓存,这在<head>标签中加入如下语句: <meta http-equiv="Pragma" content="no-c ...
- bootstrap 图片轮播效果
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="http: ...
- [html] src与href的区别
src用于替换当前元素,href用于在当前文档和引用资源之间确立联系. src是source的缩写,指向外部资源的位置,指向的内容将会嵌入到文档中当前标签所在位置:在请求src资源时会将其指向的资源下 ...
- foundation系列
1如何将布尔值转为OC对象? 1把 BOOL 值包装到 NSNumber中: NSNumber *boolNumber = [NSNumber numberWithBool:YES] 2获取BOO ...