从朋友那里得来的OGG 重启脚本,感觉很好用,分享给大家。

定时任务

00 6-20 * * * /oggdata/log/oggautorestart.sh >/oggdata/log/crontab_oggautorestart.log 2>&1
[说明]  因为晚上可以有维护操作,我们不希望在维护期间OGG 自动跑起来

脚本

oggautorestart.sh

#!/bin/bash
if [ -f ~/.bash_profile ];
then
      . ~/.bash_profile
fi

#OGG 目录
OGGHOME=/oggdata
#创建日志目录
if [ ! -d $OGGHOME/log ]; then
   mkdir $OGGHOME/log;
fi

cd $OGGHOME/log
echo "Start checking ......begin time: `date +'%Y%m%d %H:%M:%S'`" >> $OGGHOME/log/all.log
echo "info all"|$OGGHOME/ggsci|grep -E "MANAGER" >> $OGGHOME/log/status.all
echo "info all"|$OGGHOME/ggsci |grep -E "REPLICAT|EXTRACT" >> $OGGHOME/log/status.all

cat $OGGHOME/log/status.all | while read line
do
hhh=`echo $line | awk '{print $1}'`
sss=`echo $line | awk '{print $2}'`
nnn=`echo $line | awk '{print $3}'`

if [ "$hhh" = "MANAGER" ]
then
       if [ "$sss" != "RUNNING" ]
       then
               echo "$hhh is not running......start begin time: `date +'%Y%m%d %H:%M:%S'`" >> $OGGHOME/log/all.log
               echo "start $hhh" |$OGGHOME/ggsci
       else
               echo "MANAGER is running" >> $OGGHOME/log/ok.all
       fi

else
       if [ "$sss" != "RUNNING" ]
       then
               echo "$nnn is not running......start begin time: `date +'%Y%m%d %H:%M:%S'`" >> $OGGHOME/log/all.log
               echo "start $nnn" |$OGGHOME/ggsci
       else
               echo "$nnn is running" >> $OGGHOME/log/ok.all
       fi
fi

done

> $OGGHOME/log/status.all
> $OGGHOME/log/ok.all
echo "Ending check......end time: `date +'%Y%m%d %H:%M:%S'`" >> $OGGHOME/log/all.log
echo "##################" >> $OGGHOME/log/all.log

OGG 自动重启脚本的更多相关文章

  1. linux服务器挂掉自动重启脚本(转)

    实现原理主要是使用linux提供的crontab机制,定时查询服务器进程是否存在,如果宕机则执行我们预设的重启脚本. 首先我们要向crontab加入一个新任务 sudo crontab -e #进入编 ...

  2. tomcat宕机自动重启脚本

    #!/bin/bash# 获取tomcat进程ID /usr/share/tomcatTomcatID=$(ps -ef |grep tomcat |grep -w 'tomcat'|grep -v ...

  3. Memcached进程挂掉自动重启脚本

    vim memcached_check.sh   #!/bin/sh #check memcached process and restart if down PATH=$PATH:/opt/env/ ...

  4. window程序意外关闭自动重启脚本实现

    @echo off : tasklist|find /i "xxxx"||start yyyy ping/n 127.1>nul 新建 .bat 文件,将其写入文件 xxxx ...

  5. linux下通过脚本实现自动重启程序的方法

    无论什么程序都不可能完美无缺,理论上,任何程序都有 Core Dump 的一天,正式运营的程序,尤其是服务器程序,一旦 Core Dump ,后果不堪设想,有过服务器开发经验的朋友,一定都经历过深夜美 ...

  6. supervisor开机自动启动脚本+redis+MySQL+tomcat+nginx进程自动重启配置

    [root@mongodb-host supervisord]# cat mongo.conf [program:mongo]command=/usr/local/mongodb/bin/mongod ...

  7. windows程序意外关闭子订重启脚本

    window程序意外关闭自动重启脚本实现   @echo off :1 tasklist|find /i "xxxx"||start yyyy ping/n 11 127.1> ...

  8. 【运维技术】shell脚本实现线程挂掉,自动重启功能

    由于分布式系统的流行,服务器上面部署的项目都是多实例的.而我又希望有一个功能,当服务器出现异常情况能够自动重启实例. 所以我想到了使用shell脚本监控实例进程id,如果不存在的话,就重启对应的实例. ...

  9. tomcat监控,自动重启shell脚本

    tomcat监控,自动重启shell脚本如下,取名 monitor_tomcat.sh: #!/bin/sh # func:自动监控tomcat脚本并且执行重启操作 # 获取tomcat进程ID(其中 ...

随机推荐

  1. win10系统安装踩坑之路

    1.一定要下载win10原版镜像.如果用迅雷下载一定要校验文件hash值的完整性,可以用fhash.exe校验,如果哈希值不一致,一定要重新下载镜像. 2.用软媒U盘启动制作启动U盘 3.重启后按F1 ...

  2. HttpRequest Get和Post调用其他页面的方法

    HttpRequest Get和Post调用其他页面的方法,需要的朋友可以参考一下 //Get请求方式     private string RequestGet(string Url)     { ...

  3. localStorage 存储 数组

    let str = JSON.stringify(data.list); localStorage.setItem("options",str); let optionss=loc ...

  4. 纯js脚本操作excel

    纯js脚本解析excel,并渲染为htm表格,投放大屏并滚动! 代码:https://github.com/tianbogit/js_excel

  5. Mariadb/Mysql命令行常用命令

    一.初始化等 1.登陆数据库方法    mysql -u 用户名 -p 用户密码 2.修改root及用户密码 use mysql; update user set password=password( ...

  6. Asp.Net Core 客户端验证和远程验证

    我们先来看这样一个注册页面和它的后台Model @model RegisterViewModel @{ ViewBag.Title = "用户注册"; } <h1>用户 ...

  7. [CF837D]Round Subset_动态规划

    Round Subset 题目链接:http://codeforces.com/problemset/problem/837/D 数据范围:略. 题解: $dp$比较显然. 但是卡空间,有两种方法: ...

  8. Redis部分

  9. c# 面向对象/继承关系设计

    继承 RTTI RTTI 概念 RTTI(Run Time Type Identification)即通过运行时类型识别,程序能够使用基类的指针或引用来检查着这些指针或引用所指的对象的实际派生类型. ...

  10. 把cgrep mgrep集成到bashrc

    https://android.googlesource.com/platform/build/+/android-4.4.3_r1/envsetup.sh 在~/.bashrc里面增加: #Andr ...