2

After a spot of digging around I have established - I may be wrong since my knowledge of these issues is rather sketchy - that the scripts in /etc/init.d are run in the order determined by the symlinks in /etc/rcN.d.

It is not quite clear to me why I have, on Ubuntu 14.10, a whole sequence of rcN.d folders with N running from 0 to 5. runlevel indicates that the current runlevel is N 2. In /etc/rc2.d I have the files

s01rsyslog s02memcached ... so3grub-common

I assume this indicates that the s01 scripts will run prior to the s02 scripts etc.

Now here is what I need to do - run my own script in init.d AFTER everything else. Before I try it out I would like to just establish if this would be the right hting to do

  • Create the script
  • chmod +x it
  • create a symlink to it in /etc/rc2.d
  • name that symlink with s04...

I'd be most grateful to anyone who might be able to confirm that this is the right way to do things

DroidOS
  • 8,530
  • 16
  • 99
  • 171
  • Although there have been various different implementations over the years with some differences here and there, generally, it's better to say that the scripts in `/etc/rcN.d` are run. The scripts in `/etc/init.d/` are generally not run (except manually, because it's easier to remember than trying to remember which `rcN.d` directories a particular script is currently linked). Usually the master script is in `init.d`, and the `rcN.d` ones are symlinks to facilitate easy enabling/disabling of certain services). But the startup framework generally runs just the ones in `rcN.d`... – twalberg Feb 27 '15 at 21:31
  • Thanks that moves me forward a bit but it does not fully answer my question. Is my understanding that ecN.d entries starting s01 will be run prior to ones starting s02 etc? – DroidOS Feb 28 '15 at 05:17

1 Answers1

2

I finally found all the information I required regarding runlevels and more here. Hopefully, this will be useful to anyone else who runs into this question. To quote the essential bits explained there

Simply put, a 'runlevel' determines which programs are executed at system startup. Most of your exposure to run levels will deal with system startup. You will become intimately familiar with the exceptions the first time you have to troubleshoot a failed system.

Linux run levels are numbered 0 through 6. Run levels stop at six for practical and historical reasons, but it is entirely possible to have more if desired.

A brief explanation of the various runlevels:

  • 0 System Halt
  • 1 Single user
  • 2 Full multi-user mode (Default)
  • 3-5 Same as 2
  • 6 System Reboot
Community
  • 1
  • 1
DroidOS
  • 8,530
  • 16
  • 99
  • 171