This script automates the setup of automatic restart for PostgreSQL service using systemd, ensuring quick recovery in case of unexpected stops.
- Enables logging in PostgreSQL for better monitoring
- Configures systemd service file for automatic restart on failure
- Validates the setup to ensure everything works as expected
- CentOS 7.9 or compatible
- PostgreSQL 17 Server compiled version installed
- Root access to modify system configurations
- Save the script as
pg_autorestart.sh
- Make it executable:
chmod +x pg_autorestart.sh