Syed Jahanzaib – Personal Blog to Share Knowledge !

January 21, 2012

UBUNTU rc.local not executing problem and its workaround

Filed under: Linux Related — Tags: , , , — Syed Jahanzaib / Pinochio~:) @ 9:03 PM

Sometimes in ubuntu, rc.local does not execute , specially in fresh installation.
So if you encounter this issue , you can solve it by using two methods.
I have used these methods several time with success. Also make sure you command entries are above ‘exit 0‘ line
Also adding 10 seconds delay helps in few cases.

 

Method # 1 , By Using WEBMIN

Method # 2 , By Removing -e from /etc/rc.loacl file [and add 10 seconds delay]

 

Method # 1 , By Using WEBMIN

Install webmin from http://www.webmin.com/deb.html

After installati0n is done, open webmin and goto
SYSTEM > BOOTUP & SHUTDOWN
Scroll down and and Click on rc.local
Select YES on Start at boot time?

As shown in the image below.

Method # 2 , By Removing -e from /etc/rc.loacl file

Edit rc.local file by

nano /etc/rc.local

at first line remove -e  for example

Change from

#!/bin/sh -e

to

#!/bin/sh

Save & Exit, then Reboot and see, hopefully rc.local will execute on the boot.

Also adding following sleep 10 directive before any script in rc.local will help. e.g:

Example of rc.local

 

root@ahmad-desktop:~# cat /etc/rc.local
#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

# Add 10 seconds delay …

sleep 10

#Followign command will run my script for internet sharing etc / zaib

/etc/fw.sh
exit 0

 

 

Regard’s
Syed Jahanzaib