What is the difference between “service postgresql

2019-09-05 19:52发布

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?

1条回答
甜甜的少女心
2楼-- · 2019-09-05 20:32

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.

查看更多
登录 后发表回答