[ubuntu] postgres, ubuntu how to restart service on startup? get stuck on clustering after instance reboot

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.

This question is related to ubuntu ubuntu-12.04 postgresql-9.1

The answer is

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.

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

On Ubuntu 18.04:

sudo systemctl restart postgresql.service

The below command worked for me

sudo service postgresql restart

Examples related to ubuntu

grep's at sign caught as whitespace "E: Unable to locate package python-pip" on Ubuntu 18.04 How to Install pip for python 3.7 on Ubuntu 18? "Repository does not have a release file" error ping: google.com: Temporary failure in name resolution How to install JDK 11 under Ubuntu? How to upgrade Python version to 3.7? Issue in installing php7.2-mcrypt Install Qt on Ubuntu Failed to start mongod.service: Unit mongod.service not found

Examples related to ubuntu-12.04

Increasing Heap Size on Linux Machines wget: unable to resolve host address `http' How to check which PHP extensions have been enabled/disabled in Ubuntu Linux 12.04 LTS? java.lang.Exception: No runnable methods exception in running JUnits Speed up rsync with Simultaneous/Concurrent File Transfers? MySQL Job failed to start CronJob not running libz.so.1: cannot open shared object file error: could not create '/usr/local/lib/python2.7/dist-packages/virtualenv_support': Permission denied Package doesn't exist error in intelliJ

Examples related to postgresql-9.1

Postgresql SQL: How check boolean field with null and True,False Value? must appear in the GROUP BY clause or be used in an aggregate function postgres, ubuntu how to restart service on startup? get stuck on clustering after instance reboot List tables in a PostgreSQL schema PostgreSQL ERROR: canceling statement due to conflict with recovery How do I convert an integer to string as part of a PostgreSQL query? ALTER TABLE, set null in not null column, PostgreSQL 9.1 Strange PostgreSQL "value too long for type character varying(500)" PostgreSQL next value of the sequences? Change type of varchar field to integer: "cannot be cast automatically to type integer"