Ubuntu – How to associate a script at boot time to a specific run level

runlevelstartupUbuntuupstart

I am trying to understand how run levels work. I understand the meaning of the 7 run levels and I understand that they were usually configured by /etc/inittab, which used to call /etc/init.d/rc, which itself called the various scripts to configure the different run levels and how they should behave.

Right now I am on an Ubuntu Server machine (12.04) and I see that the inittab file is not used anymore and that instead, scripts are found in the /etc/init directory.

Now suppose that I want to execute a script at boot time (for example to launch an application). Usually I would do this editing the /etc/init.d/rc.local file.

And here comes my question: if I edit this file, will this script run for every run level?

If I want the script to work only at run level 5 for example, should I put this script into the /etc/rc5.d/ folder instead? Or is there another way to do this?

Best Answer

In Ubuntu, this is called Upstart. I suggest you read the Cookbook, it discusses how to create scripts to run at a specific (pseudo) runlevel.

What you're refering to, is the "System V" init system. The idea is to have things started concurrently. I suggest you take a look at the instance functionality of Upstart.

Related Question