What is the difference between "service postgresql start" and "pg_ctl start"?

10,378

The service command runs a System V-style init script. In this case you are running a script named postgreql in the /etc/init.d directory. This script likely has been written especially for Ubuntu and has the proper configuration information in it.

Share:
10,378

Related videos on Youtube

Hejag
Author by

Hejag

Updated on June 04, 2022

Comments

  • Hejag
    Hejag almost 2 years

    On Ubuntu 14.04, if i have the PGDATA environment variable set, the two commands

    service postgresql start
    

    And

    pg_ctl start
    

    seems to do the same thing: Start the postgres server in the background. Without PGDATA set, "pg_ctl start" needs needs the additional -D /datadir argument in order to start. The service does not need this. Why is this so? What is the difference between the two ways of starting the server? And how can the service start without knowing the data dir?

  • Hejag
    Hejag almost 9 years
    Yes. I guess service postgresql start will start postgres with some default location like /etc/postgresql/<version>/main. Thanks!