检测到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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。