OpenWrt Forum Archive

Topic: openwrt 'rc.local' not working on boot time

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

openwrt 'rc.local' not working on boot time. I have placed a echo commands under 'rc.local ' for testing. If i executed manually its working fine. But not working in boot time. (Once device reloaded)

vi rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

#!/bin/sh -e

echo Test_RC_Local
exit 0

ac@wrt wrote:

openwrt 'rc.local' not working on boot time. I have placed a echo commands under 'rc.local ' for testing. If i executed manually its working fine. But not working in boot time. (Once device reloaded)

vi rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

#!/bin/sh -e

echo Test_RC_Local
exit 0

I'm using rc.local a lot and everytime is working for me (after boot/reboot). Try install logger app and replace echo Test_RC_Local with logger "Test RC_local" and after boot your router up run logread. THere should be the message

Sure i will try this out and let you know.....i tried to call my own script also here, but boot time its not working and manually executed its working...i have placed my script in .init.d/ and changed the mode to 777....but no luck..

milankocvara wrote:
ac@wrt wrote:

openwrt 'rc.local' not working on boot time. I have placed a echo commands under 'rc.local ' for testing. If i executed manually its working fine. But not working in boot time. (Once device reloaded)

vi rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

#!/bin/sh -e

echo Test_RC_Local
exit 0

I'm using rc.local a lot and everytime is working for me (after boot/reboot). Try install logger app and replace echo Test_RC_Local with logger "Test RC_local" and after boot your router up run logread. THere should be the message

logger command inside the script is executing ...example,

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

logger -t 'rc.local' "Test for /etc/rc.local..."

exit 0


logread | grep rc.local
Jan  1 00:00:21 OpenWrt user.notice rc.local: Test for /etc/rc.local...

But echo messages are not printing also script commands also not executing on bootup time...

milankocvara wrote:
ac@wrt wrote:

openwrt 'rc.local' not working on boot time. I have placed a echo commands under 'rc.local ' for testing. If i executed manually its working fine. But not working in boot time. (Once device reloaded)

vi rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

#!/bin/sh -e

echo Test_RC_Local
exit 0

I'm using rc.local a lot and everytime is working for me (after boot/reboot). Try install logger app and replace echo Test_RC_Local with logger "Test RC_local" and after boot your router up run logread. THere should be the message

ac@wrt wrote:

logger command inside the script is executing ...example,
...
But echo messages are not printing also script commands also not executing on bootup time...

There is no console when that is run at boot. So where would "echo" print its message????
If you want output at boot, you need to use logging facility, meaning "logger" and read the system log via "logread".

Which script commands do not execute there properly? I guess there might be similar reasons (the absence of a console).

You might also trying to issue your script commands in a detached way with "&" at the end.
E.g.  "command parameters &"

ps. If you want better answers, please show the exact script commands that fail for you. Maybe then somebody can figure out why just those commands fail.

(Last edited by hnyman on 28 Nov 2016, 10:20)

Thanks, I am trying the following commands

uci set system.@system[0].log_size=4096
uci set system.@system[0].log_type=file
uci set system.@system[0].cronloglevel=5
uci set system.@system[0].log_file= /etc/AP_log_Arun.log
uci set wireless.radio0.log_level=3
uci commit system
uci commit wireless

/etc/init.d/log restart


hnyman wrote:
ac@wrt wrote:

logger command inside the script is executing ...example,
...
But echo messages are not printing also script commands also not executing on bootup time...

There is no console when that is run at boot. So where would "echo" print its message????
If you want output at boot, you need to use logging facility, meaning "logger" and read the system log via "logread".

Which script commands do not execute there properly? I guess there might be similar reasons (the absence of a console).

You might also trying to issue your script commands in a detached way with "&" at the end.
E.g.  "command parameters &"

ps. If you want better answers, please show the exact script commands that fail for you.

I think that it is working perfectly well. But normally you just cannot see the output of the boot process, unless you are connected, for example, with a serial console. Or try the dmesg command; maybe you can find the output somewhere at the end.

What would you like rc.local to do for you?

By the way, I believe the #!/bin/sh -e line is not necessary (but does not influence neither, I tested it).

once after system init, i trying to create a Logging file and restart the log process vis rc.local

maartenjd wrote:

I think that it is working perfectly well. But normally you just cannot see the output of the boot process, unless you are connected, for example, with a serial console. Or try the dmesg command; maybe you can find the output somewhere at the end.

What would you like rc.local to do for you?

By the way, I believe the #!/bin/sh -e line is not necessary (but does not influence neither, I tested it).

If may be a question of asyncronous starting of network and other init scripts, or other timing issues. If you search for previous discussions for problems with /etc/rc.local, one solution that has helped many is adding a "sleep 15" (or 30) command before the actual commands.

I used the approach of having both a detached shell with "(...)&" and a sleep command when I wanted to have the NTP-updated time printed to the log at the end of the boot. For me the sleep was necessary to give NTP enough time to sync from internet:

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

(sleep 15 ; logger -t "syslog" - ntp client should have set time by now -)&
exit 0

(Last edited by hnyman on 28 Nov 2016, 11:01)

The discussion might have continued from here.