What's new

init-start script not executing at boot

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

cgull

New Around Here
For some reason my init-start script is not running although it works when called explicitly. I am running an RT-AC68P with 378.55_0. Any thoughts on what the issue could be?

Code:
admin@RT-AC68P-0000:/tmp/home/root# ls -la /jffs/scripts/init-start
-rwxrwxrwx    1 admin    root            76 Aug 14 14:54 /jffs/scripts/init-start

admin@RT-AC68P-0000:/tmp/home/root# cat /jffs/scripts/init-start
#!/bin/sh
sleep 10
/usr/sbin/cru a ScheduledReboot "0 4 * * * /sbin/reboot"


admin@RT-AC68P-0000:/tmp/home/root# cru l
admin@RT-AC68P-0000:/tmp/home/root#

admin@RT-AC68P-0000:/tmp/home/root# /jffs/scripts/init-start
admin@RT-AC68P-0000:/tmp/home/root# cru l
0 4 * * * /sbin/reboot #ScheduledReboot#
 
Last edited:
For some reason my init-start script is not running although it works when called explicitly. I am running an RT-AC68P with 378.55_0. Any thoughts on what the issue could be?
Hi,

You can add the additional lines below into the script to get everything logged into a file in the /tmp folder. This is in general a good practice for debugging purposes and can be left in the script for easier checking.

The script enhancement can be used for every user script as it creates a log file per script named same as the user script.

With kind regards
Joe :cool:

Start logging at the beginning of the script with these lines:
#!/bin/sh
# START of the script logging
/usr/bin/logger -t START_$(basename $0) "started [$@]"
SCRLOG=/tmp/$(basename $0).log
touch $SCRLOG
NOW=$(date +"%Y-%m-%d %H:%M:%S")
echo $NOW "START_$(basename $0) started [$@]" >> $SCRLOG
# Un-comment the next line to enable detailed logging of all commands in the script!
# exec 3>&1 4>&2 >$SCRLOG 2>&1
#
# Add your script commands here
#
# STOP of the script logging
NOW=$(date +"%Y-%m-%d %H:%M:%S")
if [ "$?" -ne 0 ]
then
echo $NOW "Error in script execution! Script: $0" >> $SCRLOG
else
echo $NOW "Script execution OK. Script: $0" >> $SCRLOG
fi
/usr/bin/logger -t STOP_$(basename $0) "return code $?"
# Un-comment the next line to stop the detailed logging of all commands in the script!
# Need to be in line with the un-commenting of the enable line: both un- or commented out!
# exec 1>&3 2>&4
exit $?
 
Hi,

You can add the additional lines below into the script to get everything logged into a file in the /tmp folder. This is in general a good practice for debugging purposes and can be left in the script for easier checking.

The script enhancement can be used for every user script as it creates a log file per script named same as the user script.

With kind regards
Joe :cool:

Start logging at the beginning of the script with these lines:


Ok, I can run it successfully interactively but it still is not being invoked at boot. Output...

Code:
admin@RT-AC68P-0000:/tmp/home/root# more /tmp/init-start.log
2015-08-15 11:25:10 Script execution OK. Script: /jffs/scripts/init-start
 
init-start is a bit too early for manipulating cron. I suggest using services-start instead.
 
I don't think which script file is the problem here. I'm running an init-start script with a cron job also and it runs just fine.

Remove the sleep 10 line and see if that works. Also don't forget to remove the logging. You don't want to have the system writing a log file to the NAND every time. The NAND doesn't have very high write endurance.
 
I hate to ask an obvious question, but....You did enable the running of User scripts in the gui, right? Is there a log entry in syslog saying it found the script?
 
I hate to ask an obvious question, but....You did enable the running of User scripts in the gui, right? Is there a log entry in syslog saying it found the script?

Good call, this was the problem, I'm a noob with Asus and Merlin so didn't realize this needed to be enabled.

Thanks
 
Good call, this was the problem, I'm a noob with Asus and Merlin so didn't realize this needed to be enabled.

Thanks
No problem.....that was actually a fairy recent change that the running of scripts was disabled after a factory reset. This way, if there is something in the scripts that is preventing the router from booting successfully, you can factory reset and get back in.
 
I don't think which script file is the problem here. I'm running an init-start script with a cron job also and it runs just fine.

Remove the sleep 10 line and see if that works. Also don't forget to remove the logging. You don't want to have the system writing a log file to the NAND every time. The NAND doesn't have very high write endurance.

I won't dispute if you can or can't do in init-start. There are a couple of hooks in Merlin. I could hack up something that probably will work in all of them..for most of stuff. But I would ask why on earth it's so time critical to schedule a cron job right after loading the kernel? If the answer is no, then let's find a better place.

services-start is the better place. My comment holds true regardless init-start works or not. And that's how some ppl keep their Asus robust.
 
Sorry for waking up such an old thread, but I came here trying to resolve a similar problem — init-start wasn't (seemingly) working on Asus RT-AC86U at 386.7 Merlin firmware. That was at least my thought after a logger command added there wasn't appearing in System log:

Code:
logger "================== init-start hook started...===================="

However the true reason is simply that logger is not working at this stage. It just silently fails to output any message, no warning or error, no matter you run it as logger or /usr/bin/logger. The "touch" method that Merlin suggests in the Wiki, produces a file, my own stuff i put there also works, so init-start actually is running, it's just the logger that doesn't work.

Logger works perfectly with same messages in other scripts.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Top