Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between /etc/init.d and /sbin/service

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)

like image 283
ObiWanShanobi Avatar asked Jul 19 '14 04:07

ObiWanShanobi


People also ask

What is the difference between init and init D?

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.

What is the purpose of ETC init D?

/etc/init. d is a directory containing initialization and termination scripts for changing init states.

How is etc Systemd different to ETC init D?

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.

What is init D service?

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.


1 Answers

/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 /.

like image 89
Khary Mendez Avatar answered Oct 13 '22 23:10

Khary Mendez