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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
This comment has been deleted
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:
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
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Sign up now
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.
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/