35

I want to be sure in what order services are started during boot process in Debian based systems (Debian Squeeze in particular).

6 Answers 6

40

In short:

ls /etc/rc*.d

This shows you what starts at which runlevel, and within each level the order is determined by the number after the letter (K is Kill, S is start).

You can configure what starts at each runlevel with sysv-rc-conf, which is installable with apt.

e.g. on my system apache2 is symlinked in rc5.d as "S20apache2". A link in the same directory with S19 would start before it, something with S21 would start after it.

Further reading:

3
  • Thank you very much but I need to be sure that for instance chilli is started before bind9 but both of them has S21 prefix. I edited particular /etc/init/ files Required-Start: and Required-Stop: section and I've ran update-rc.d for them. Any ideas what could go wrong?
    – user155872
    Jan 24, 2013 at 12:41
  • You probably want insserv rather than update-rc.d. Is Chili a bespoke app or in the Debian repo? If it's a properly made Debian package you shouldn't need to edit its init script, but if it's bespoke try X-Start-Before rather than Required-Start (and then enable with insserv). Link: wiki.debian.org/LSBInitScripts Jan 24, 2013 at 14:01
  • OK, thank you. I've learned about insserv and one more thing: "dollar sign, because they are predefined virtual facilities. Otherwise, the names of System V boot scripts, found in /etc/init.d/, should be used, although without a dollar sign or possible .sh extension." And now prefixes are correct. Thanks :)
    – user155872
    Jan 24, 2013 at 15:33
20

Would rcconf and sysv-rc-conf utilities help?

# aptitude install rcconf sysv-rc-conf

Afterwards you can run them by typing rcconf or sysv-rc-conf.

rcconf sysv-rc-conf

9

You can list all services and their status with this simple command:

service --status-all

From the manual:

service --status-all runs all init scripts, in alphabetical order, with the status command. The status is [ + ] for running services, [ - ] for stopped services and [ ? ] for services without a 'status' command. This option only calls status for sysvinit jobs; upstart jobs can be queried in a similar manner with initctl list.

3
  • 1
    I don't think this addresses the "what order" part of the question.
    – kmarsh
    Oct 30, 2015 at 14:58
  • 3
    and this also does not really tell which one is enabled (start on boot)
    – kiltek
    Apr 3, 2017 at 13:48
  • I have scripts that show up in this command, but they aren't started up.
    – Owl
    Nov 1, 2018 at 11:06
4
for i in `find /etc/rc*.d -name S*`; do basename $i | sed -r 's/^S[0-9]+//'; done | sort | uniq

Sample output:

acpid
anacron
avahi-daemon
boa
bootlogd
bootlogs
bootmisc.sh
checkfs.sh
checkroot-bootclean.sh
checkroot.sh
cryptdisks
cryptdisks-early
dbus
delayed-services
hostname.sh
hwclock.sh
keyboard-setup
killprocs
kmod
lightdm
mountall-bootclean.sh
mountall.sh
mountdevsubfs.sh
mountkernfs.sh
mountnfs-bootclean.sh
mountnfs.sh
mtab.sh
pppd-dns
procps
qemu-kvm
rc.local
rmnologin
rsyslog
single
sleep
stop-bootlogd
stop-bootlogd-single
udev
udev-mtab
x11-common
1

On Debian rcconf should do the trick, just to configure stop/start of already present services.

I use it all the time on Debian Jessie and Wheezy.

1
  • Could you explain a little more how to use the tool you've mentioned?
    – womble
    Sep 1, 2015 at 0:44
0

systemd

On distros using systemd, you can control the order you have to use a combination of Requires with Before/After. Due to the parallel and relationships among services, the service start-up order isn't deterministic.

Use systemd-analyze plot

# This command prints an SVG graphic detailing which system services have been started at what time, highlighting the time they spent on initialization.
systemd-analyze plot > startup_order.svg

and systemd-analyze dot

# to generate a graphical dependency tree.
systemd-analyze dot | dot -Tsvg > systemd.svg 

Source and more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.