Get in touch:
01524 851 877
07718 896 553

Running Scripts At Startup On Ubuntu

Posted on Jun 05 2009

With a lot of the boxes I set up I write at least one custom script that needs to be run at boot time to configure a bunch of stuff for one reason or another.

The scripts themselves are irrelevant but making sure they run when the machine boots is obviously important.

It is a simple process but I often forget the command so it’s going on here. Create the script you want to run and plonk it into /etc/init.d/.

Now make the script executable.

chmod +x /etc/init.d/script.sh
Now that is done you need to inform the system that you have a new script that you want to be run on startup. On Ubuntu this is done as follows.

update-rc.d script.sh defaults
The defaults argument puts a link to the scripts start procedure at run levels 2, 3, 4 and 5. It also puts a link to the scripts stop procedure at run levels 0, 1 and 6. For more information on how to configure this more finely look at man(8) update-rc.d.