Run Script On Boot Process In Ubuntu

Sometimes 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.

Comments

  1. Geplanet says:

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

  2. Carl says:

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

  3. Venereo says:

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

  4. Victor says:

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

Give me your feedback

This site uses Akismet to reduce spam. Learn how your comment data is processed.