PostgreSQL Server Process Check startup script

Source: Internet
Author: User
Tags postgresql

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.