For some services (ex: bluetooth) I have entries in both /etc/init.d/
and in /etc/init/
directory.
How do I know how this service is started ? By sysvinit
or upstart
?
I am using Ubuntu 14.04.
For some services (ex: bluetooth) I have entries in both /etc/init.d/
and in /etc/init/
directory.
How do I know how this service is started ? By sysvinit
or upstart
?
I am using Ubuntu 14.04.
You may have two sets of scripts, but you only have one active init system. On Ubuntu 14.04, that's Upstart.
So no matter whether your script is under
/etc/init.d
or/etc/init
, the answer for which init system runs your script under Ubuntu 14.04 is always Upstart.You can watch what happens when you try run an
/etc/init.d
script by usingstrace
to log the system calls to STDOUT:First you'll see that the init script first loads some header functions through
/lib/lsb/init-functions
Pretty soon you'll see the activity diverted to an Upstart related script:
That's just a shell script, so you can open it and read the source to see what it does.
As you continue to full the output, I think you'll see that command is redirected to start the script using the Upstart script instead of the SysV init script.
What's interesting to see is that on 16.04, Upstart further redirects the control to systemd, and the related systemd service is started instead:
The bottom-line advice to use Upstart scripts and service management commands on Ubuntu 14.04 to avoid the complexity and potential confusion of the SysV init compatibility layer. Likewise, once you upgrade to 16.04, start using the native
systemd
unity files andsystemctl
command to avoid involve unnecessary compatibility layers.