May 26, 2010 by  

Run Script On Boot Process In Ubuntu

Ubu_Icon2Sometimes you need to run a script on boot process, for example run an iptables config at boot process. So you don’t have to run the script manually every rebooting.

You can run your script on boot process in Ubuntu by adding it to /etc/init.d/rc.local file. Look the steps below.

1. Open /etc/init.d/rc.local file with this command:

vim /etc/init.d/rc.local

2. Add your script that you want to run on boot process there, for example:

sh /home/ivan/iptables.sh
echo 'Iptable Configured!'

3. Save the files. And your script will run on boot process.

PS: This steps only work on Ubuntu. If Debian you need to run

update-rc.d filename defaults 80

For another distribution like Centos, Redhat or Fedora, please refer to their documentation.

What people search:

Post comment as twitter logo facebook logo
Sort: Newest | Oldest

thanks you are marvelous.My server now runs as a router and a webserver .thanks again

actually /etc/init.d/rc.local just calls /etc/rc.local, so you can edit this last directly

Thanks for the tip! That worked like a champ. I needed to load the No-IP update daemon at startup.

It doen't work in Lucid. Lucid ignores rc.local, I don't know why.

Probably, because Ubuntu uses Upstart, the new SysV init replacement.

Try to use /etc/init.d/rc.local stop|start to see if it works.
It has worked fine to me