简体   繁体   中英

What is the difference between “service postgresql start” and “pg_ctl start”?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM