您好,登錄后才能下訂單哦!
檢測到PostgreSQL Server進(jìn)程 down 的時候啟動,running狀態(tài)無動作
# 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
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。