PostgreSQL Server进程检查启动脚本

前端之家收集整理的这篇文章主要介绍了PostgreSQL Server进程检查启动脚本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

检测到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

猜你在找的Postgre SQL相关文章