i need postgres service restarts automatically when it crashed or shut down abruptly? I would like to do this batch script. I tried the following pg_ctl -w restart but it did not worked.
Asked
Active
Viewed 129 times
1 Answers
0
I am assuming you are using a windows based system. In Services application, select the service and see the properties of the service.
Click on recovery tab, and set First and Second failure to RESTART the Service. And third to run a batch program that BLAT's will email you the third failure notification. (Third is optional if you don't want en email)
Also you need to set the "Reset Fail Count" to 1 Daily. To do it via a command line you may run
SC failure w3svc reset= 432000 actions= restart/30000/restart/60000/run/60000
SC failure w3svc command= "FailNotificationBatchFile.CMD"
Your FailNotificationBatchFile.CMD file will have:
blat - -body "Your Postgres Service Crashed third time in a day" -subject "POSTGRES SERVICE CRASH" -to Notify@gmail.com -server
So to summarise: Open Services.msc, click on the service to open the Properties of the service, there is a Recovery tab and those settings should allow you to restart the service upon failure.

Martijn Pieters
- 1,048,767
- 296
- 4,058
- 3,343

Amjad Shahzad
- 706
- 5
- 12
-
Thank you @Amjad Shahzad , will give it a try – Maredi NaveenKumar Apr 24 '20 at 16:23
-
1Are you able to try it? Did it worked for you. If yes then will you please mark this answer as accepted for the record. Thanks – Amjad Shahzad Apr 27 '20 at 12:24