postgres, ubuntu how to restart service on startup? get stuck on clustering after instance reboot
UbuntuUbuntu 12.04Postgresql 9.1Ubuntu Problem Overview
I have a Postgres db 9.1
running on AWS EC2
, with ubuntu 12.04
.
I messed a lot with the instance (i.e installed all kinds of postgres X.X before i settled on 9.1).
Now after a month working on that db, I discovered that if I restart my instance postgres
doesn't load correctly, its status says "Running clusters". this will last forever until I
sudo service postgresql restart
from terminal, and then it works again.
How do I add this line, to ubuntu startup so that each time it loads, it will restart this service, and hopefully solve my problem?
Also any other solution which might solve this.
Ubuntu Solutions
Solution 1 - Ubuntu
On Ubuntu 18.04:
sudo systemctl restart postgresql.service
Solution 2 - Ubuntu
The below command worked for me
sudo service postgresql restart
Solution 3 - Ubuntu
I guess it would be best to fix the database startup script itself. But as a work around, you can add that line to /etc/rc.local
, which is executed about last in init phase.
Solution 4 - Ubuntu
ENABLE is what you are looking for
USAGE: type this command once and then you are good to go. Your service will start automaticaly at boot up
sudo systemctl enable postgresql
DISABLE exists as well ofc
Some DOC: freedesktop man systemctl
Solution 5 - Ubuntu
restart postgresql
$ sudo service postgresql restart
Solution 6 - Ubuntu
for ubuntu startup so that each time it loads, it will restart this service of Postgres on startup so that you won't have to restart it all the time
sudo update-rc.d postgresql enable