What's the difference between starting daemons (tomcat for example) with /etc/init.d and /sbin/service? Is there a benefit to using one or the other?
Running CentOS release 5.8 (Final)
Directories and Configs /etc/init is where the upstart init configs live. While they are not scripts themselves, they essentially execute whatever is required to replace sysvinit scripts. /etc/init. d is where all the traditional sysvinit scripts and the backward compatible scripts for upstart live.
/etc/init. d is a directory containing initialization and termination scripts for changing init states.
Init and Systemd are both init daemons but it is better to use the latter since it is commonly used in recent Linux Distros. Init uses service whereas Systemd uses systemctl to manage Linux services.
d is the directory that stores services control scripts, which control the starting and stopping of services such as httpd, sshd, etc. rc. local is a service that allows running of arbitrary scripts as part of the system startup process.
/sbin/service simply runs the corresponding script in /etc/init.d The advantage of running /sbin/service is that it sets up a "clean" environment first. From the service man page:
service runs a System V init script or upstart job in as predictable an environment as possible, removing most environment variables and with the current working directory set to /.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With