I have seen two ways to start a postgresql server:
/sbin/service postgresql-9.1 start
/etc/init.d/postgresql-9.1 start
Could anyone explain the difference between these two? Or there's no difference at all?
The OS we are using is CentOS 6.2
On your system, and most "older" systems, service
does the same thing as running the init script. Depending on the implementation, it might set a more predictable environment, so it's still preferred to use it if available.
The general idea, however, is that service
will also work with newer init systems. So for example, if you have Upstart, then service
will instead of running some script signal the Upstart system to start or stop a service. So to be future-proof, use service
.
None.
/sbin/service is just generic script that will run init script and pass the command (you will see if you take a look at /sbin/service)
So basicly now you can say: service name command[start/stop/status/restart/...]