By suraphan
I’m using PostgreSQL and it often stops working. I want the service of ‘postgreql’ to start automatically according to the article Configuring MYSQL To Auto-start After Boot using systemd which I have tried following but still not working, anyone have an example?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @suraphan,
Systemd allows you to configure a service so that it automatically restarts in case it’s crashed.
You can however let systemd auto-restart it in case it fails or is accidentally killed. To do so, you can add the Restart option to the [Service] stanza.
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
Restart=on-failure
RestartSec=5s
ExecStart=/path/to/daemon
The above will autorestart after your service in this case postgresSQL crashes. Just add the above code to your PostgreSQL Deamon. It should be somewhere in /etc/systemd/system/
Hello,
In addition to what has already been mentioned regarding automatic restarts after a service crash, you could also enable the service so it starts after a server reboot:
- systemctl enable postgresql
Also if your service is crashing often, I would recommend checking your server logs to find out the root cause of the issue. It is likely that your server needs more memory.
Best,
Bobby
This comment has been deleted
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.