initsystem upstart systemd init.d
The init system for 14.04 is upstart. The init system for 16.04 is systemd
/usr/lib/systemd
tells you you're on a systemd based system./usr/share/upstart
is a pretty good indicator that you're on an Upstart-based system./etc/init.d
tells you the box has SysV init in its history
Using Services
Please note that generally, you can use either traditional sysvinit scripts and the methods of working with them as well as the new upstart configs and the command: "service" interchangeably. It is however recommended you use the new upstart methods which are both forward and backward compatible.
Starting a Service
# Traditional: /etc/init.d/myservice start # Upstart service myservice start
Stopping a Service
# Traditional: /etc/init.d/myservice stop # Upstart service myservice stop
Getting a list of Services
# Traditional: ls /etc/init.d # Upstart: service --status-all
------------
The init process is always assigned PID 1. The
/proc
filesystem provides a way to obtain the path to an executable given a PID.
In other words:
nathan@nathan-desktop:~$ sudo stat /proc/1/exe
File: '/proc/1/exe' -> '/sbin/upstart'
As you can see, the init process on my Ubuntu 14.10 box is Upstart. Ubuntu 15.04 uses systemd, so running that command instead yields:
nathan@nathan-gnome:~$ sudo stat /proc/1/exe
File: '/proc/1/exe' -> '/lib/systemd/systemd'
/usr/lib/systemd
tells you you're on a systemd based system./usr/share/upstart
is a pretty good indicator that you're on an Upstart-based system./etc/init.d
tells you the box has SysV init in its history
Unless you are using 15.04 or any later release (which uses
systemd
), you will probably be better off if you turn your script into an Upstart job, rather than follow the examples you'll find in /etc/init.d/
(which are System V-style init scripts, which Ubuntu and other distributions are moving away from).
In
systemd
, the target of most actions are "units", which are resources that systemd
knows how to manage. Units are categorized by the type of resource they represent and they are defined with files known as unit files. The type of each unit can be inferred from the suffix on the end of the file.
For service management tasks, the target unit will be service units, which have unit files with a suffix of
.service
. However, for most service management commands, you can actually leave off the .service
suffix, as systemd
is smart enough to know that you probably want to operate on a service when using service management commands.sudo systemctl start application.service sudosystemctl start
application
To get a list of the installed services on the shell, you may use this command (on Fedora, RedHat, CentOS, SuSE, and Mandriva):
chkconfig --list
Comments
Post a Comment