Running scripts x minutes after boot

For reference, my routers are Linksys EA8300.

Looking to run a couple of scripts a few minutes after my router has booted to start some servers.

Running these scripts as init scripts seem to stall the router from "fully booting" in a sense - the WPS light on my router stays flashing when normally it does not do this. Normally the router's logo lights up and the WPS light is off.

I've looked into using cron, but it doesn't quite fit what I'm looking for, since it seems like it can only schedule tasks based on clock time instead of time after boot. What other options are out there to do this?

1 Like

You can use /etc/rc.local.
If the delay is constant:

sleep 300

If the delay is different, add sleep X to the beginning of each script and run all scripts in background:

/root/script1 &
/root/script2 &
1 Like

Pavel for those with a graphical lean how would this be delayed by 120 seconds.

ntpd -d -n -q -N -I eth0 -p -p

Thanks Pavel/Jim

What notation in the code (if any) makes this background, or is the term background a given as it is running from /etc/rc.local

The ampersand (&)


Thanks Jim, does that mean it is not sent to the system log?

You edit the same file using the GUI, so just add the delay above the command or use the && operator.

If the script does not run in background, the next script will start after the execution of the previous one.
Thus the scripts will start sequentially and the delays also will be sequential (superimposed).
Using the & operator will make all scripts run at the same time.

1 Like

You can probably redirect the script output (stdout and stderr) to logger.

1 Like

The OP's question is relevant and in order to absorb the solution, I have to visualize how it pertains to the item I have in /etc/rc.local.

For the record, I did not intended to delay this ntpd from executing and it is logged.

Tue May 17 14:21:42 2022 daemon.notice procd: /etc/rc.d/S95done: ntpd: sending query to

@anon89577378 I misunderstood what the term "background" meant in context to the function. >incorrectly thinking silent< :brick::face_with_diagonal_mouth::brick:

Thank you both for insights.

1 Like

I'd suggest to include these in another script and call the script with & in /etc/rc.local

Otherwise the booting process will not finish until the last script exits, which may not be desirable.

1 Like

Good point.

My current problem is exactly this - I'm currently starting some servers via init scripts. However, it seems that the booting process is stalled indefinitely since the first server initialized keeps running (the other servers never get initialized) until the process is killed.

Would putting the scripts/commands in local startup aka /etc/rc.local fix this issue?

For example, the following would be inside /etc/rc.local :

sleep 300
command 1 &
command 2 &

Still learning the ropes with Linux.

Still not a good idea, as boot process will delay 5 minutes for no reason.
Either you put all of them in another script and run that script in rc.local with & , or create a service which will run the script and you don't care about the &.


What's the difference between putting two commands into rc.local directly, each with an & at the end, and your method, where you put the two commands into one separate script, and call the script with an & at the end?

It's three commands, you forgot to count sleep.
Other than that you might want to keep one command running without sending it to background for some reason. This way you'd need to add them in a script and not run them in rc.local directly.