Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My runlevel 0 scripts in /etc/rc0.d, which should be executed when stopping are for example

  1. K05foo -> ...
  2. K10bar -> ...
  3. K80baz -> ...
  4. S10somemore -> ...
  5. S90halt -> ...

Is it correct, that the excution order is as listed above, that is

  1. First all Kills, in ascending priority order
  2. Then all Starts, in ascending priority order
  3. All this, independently of the runlevel to which we switch (S,0-6)
  4. All scripts always get called (ie. there is no additional checks which would prevent a script to be called, for example whether in the previous runlevel that script was in fact started)

I'm confused because on my embedded system some of the scripts don't seem to get executed, and that page says

S20 link is started before a S91 and and K91 is kill before K20.

which contradicts my text above.

share|improve this question
up vote 1 down vote accepted

Answering my own question, for the sake of completness:

I'm using busybox on an OpenEmbedded system. The rc script in /etc/init.d/rc has the following behavior:

  • In the target runlevel, all Kills are executed before all Starts
  • All scripts are executed in ascending priority order
  • But: Starts are only executed if in the previous runlevel there wasn't also an equivalent start (ie. it's newly starting)
  • And, if the target runlevel is 0 (halt) or 6 (reboot), then starts are actually executed as Kills - ie "stop" is passed as argument. But still after all Kills, and still not if an equivalent start existed in the previous runlevel.

Additionally, what bit me was that shutdown now actually switches to runlevel 1 and not runlevel 0. You have to use halt or powerofffor runlevel 0. So my scripts in rc0.d where not really executed, only the ones which happened to also be in rc1.d.

share|improve this answer

It depends on the init daemon you are using.

For SysVInit you can assume something like the following to happen when you change the runlevel to 0:

for k in /etc/rc$rl.d/K*; do
  $k stop
for s in /etc/rc$rl.d/S*; do
  $s start

I can't see a contradiction of the sentence you cited to the things you said above.

share|improve this answer
the contradiction concerns the order of K scripts. The debian authoritative manual claims both S and K are ascending, yet the sentence claims different order for S and K. Of course this is implementation specific. – Dani_l Jul 11 '14 at 12:30
I'm using busybox. The actual script launcher is /etc/init.d/rc and it contains the following comment. Optimization feature: A startup script is _not_ run when the service was running in the previous runlevel... So this answers my question. Thanks again. – Philipp Jul 11 '14 at 12:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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