When the PostgreSQL server process down is detected, the running state is no action
# 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 user login, script added to Cron
*/2 * * * */opt/cron/pg_server_check.sh
This article is from the "Yiyi" blog, make sure to keep this source http://heyiyi.blog.51cto.com/205455/1890791
PostgreSQL Server Process Check startup script