Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The PostgreSQL Server process checks the startup script

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Starts when the PostgreSQL Server process down is detected, and the running status has 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% HRV% MVR% 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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report