码迷,mamicode.com
首页 > 数据库 > 详细

PostgreSQL Server进程检查启动脚本

时间:2017-01-10 18:18:37      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:postgresql server进程 down

检测到PostgreSQL Server进程 down 的时候启动,running状态无动作


# more pg_server_check.sh 


#!/bin/sh


export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin


prefix=/etc/init.d


DAEMON="$prefix/postgresql"


RUNN_STR="server is running"


Pg_Status=`$DAEMON status|grep "$RUNN_STR"`


LOG_PATH=/opt/cron


CHECK_LOG=$LOG_PATH/pg_server_check.log


Error_log=$LOG_PATH/pg_server_check_Error.log


echo "$Pg_Status"


DT_STR=`date +‘%Y-%m-%d %H:%M:%S‘`


if [ -z "$Pg_Status" ]

then

    echo "Check Time: $DT_STR " > $Error_log

    echo "Error: PostgreSQL Server is down." >> $Error_log

    echo "$DAEMON start"|sh >> $Error_log

else

    

    echo "Check Time: $DT_STR " > $CHECK_LOG

    echo "PostgreSQL Server is running,do nothing." >> $CHECK_LOG

fi


root用户登录,脚本加到cron


*/2 * * * * /opt/cron/pg_server_check.sh


本文出自 “yiyi” 博客,请务必保留此出处http://heyiyi.blog.51cto.com/205455/1890791

PostgreSQL Server进程检查启动脚本

标签:postgresql server进程 down

原文地址:http://heyiyi.blog.51cto.com/205455/1890791

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!