Until 15.04 upstart was used for this, then being replaced by systemd.
Used until Ubuntu 15.04: upstart
When you press the shutdown button or execute shutdown +0 in a terminal, upstart executes every script in /etc/rc0.d in alphabetical order.
When you press the reboot button or execute shutdown -r +0 in a terminal, upstart executes every script in /etc/rc6.d in alphabetical order.
Edit: Note that the +0 in the above commands indicates the number of minutes to wait prior to taking the requested action and is equivalent to now. If you have other users on the system it would be prudent to increase this value to allow them time to save their work.
Both directories hold only symlinks whose targets are located in
/etc/init.d/ though.
For more information see /etc/init.d/README and man init.
Until 15.04
upstart
was used for this, then being replaced bysystemd
.Used until Ubuntu 15.04: upstart
When you press the shutdown button or execute
shutdown +0
in a terminal,upstart
executes every script in/etc/rc0.d
in alphabetical order.When you press the reboot button or execute
shutdown -r +0
in a terminal,upstart
executes every script in/etc/rc6.d
in alphabetical order.Edit: Note that the
+0
in the above commands indicates the number of minutes to wait prior to taking the requested action and is equivalent tonow
. If you have other users on the system it would be prudent to increase this value to allow them time to save their work.Both directories hold only symlinks whose targets are located in
/etc/init.d/
though.For more information see
/etc/init.d/README
andman init
.Used from Ubuntu 15.04 on: systemd
Here some links concerning
systemd
: