Can same level runlevel scripts have the same priority? For instance, can say runlevel x have these 2 scripts: S10ScriptName1 and S10ScriptName2 ? If so, what is the execution order?


It depends on the exact implementation your distro is using (and sometimes the configuration), but one of:

  • Alphabetical, by some definition of alphabetical, likely the LC_ALL=C one. This is basically the easy way to implement it, and a common one. It's why the numbers are 0-prefixed, to make sure that a plain old sort puts them in the right order.
  • In parallel. This is what startpar without -M did, back in the days of Debian Lenny.
  • The numbers don't control, order is determined by LSB headers declaring dependencies: what insserv/startpar -M does. Or what other init systems' (e.g., systemd) SysV compatibility layers do.

You would need to check the documentation for your system or the code (which under SysV init was often shell scripts, so relatively easy to check; you can find where it is by reading /etc/inittab).

  • Hi derobert, I have an embedded version (QNAP 4.3.3.xxxx). I noticed that instead of the familiar rc#.d they use the rcK.d and rcS.d for the startup scripts. I am learning about runlevels as the software I was trying to install used the rc#.d structure. I noticed that the scripts in rcK.d and rcS.d directories follow the naming pattern K##Scriptname or S##Scriptname, respectively, and ## in not repeated in a directory. My question is should I use highest ## (+1 or so) and rename my script, i.e. if highest ## is 60, should I use 61 or higher? Inversely for the rcK.d directory – Juan Miguel Ruiz-Olivares May 1 at 20:47
  • @JuanMiguelRuiz-Olivares you'd use whatever numbers get your scripts ordered properly (which may also mean you need to renumber existing scripts), unless it uses insserv (in which case you'd run that, and it'll handle it). But see also wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup — that seems to say plopping files in rc.X is the wrong approach. No idea as I don't personally have access to any QNAP devices.You can ask a new question if needed. – derobert May 1 at 21:17

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.