Reputation: 21
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.
Upvotes: 0
Views: 171
Reputation: 822
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 [email protected] -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.
Upvotes: 0