0

I wrote while true; do ping 10.9.0.1; sleep 1; done on /etc/rc.local on an embedded board. I have been waiting longer than 20 minutes that it does not get the log in prompt. Either it got stuck on the boot or boot works extremely slow (normally it takes less than 2 minute to get the log in prompt on my device).

I can fix it by inserting the SD card into my laptop and remove the while(1). But I wonder if I did such thing on a PC/laptop, would it be possible to fix it without need of re-installing the distro?

  • if I did such thing on a PC/laptop -> If it can boot from CD you could fix it with a live CD. – goldilocks Nov 7 '14 at 20:12
2

Firstly, as written, your ping will run forever unless it us unable to find the host, because it runs until it catches a signal (i. e. SIGINT) telling it to stop.

Scripts in /etc/rc.local are not, as far as I recall, run in the background. As such, your script never finishes as it is an infinite loop. Depending on exactly why you are doing this, you could either background it or change it to exit when a condition is met.

If you are doing this to delay until a network comes up, you could:

while ! ping -c1 10.9.0.1; do
   sleep 1
done

Or, if you really do want a once-per-second ping running in the background, you could use screen or nohup or disown to detach the process from the shell and allow the boot to proceed.

Either way, this is a potentially dangerous thing to do, as you don't have any means to stop the script at boot-time if things go awry.

You might be better served with a script in /etc/init.d/ which is tied to your chosen runlevel that has enough logic to abort if things take too long.

  • thank you for the information. I have the board running more than 40 min like this. It does not get the log in prompt. I am curious if there is any solution to that without need of removing the SD card? – Angs Nov 7 '14 at 19:49
  • If sshd is running you could try that, hopefully the process you have to kill is called rc.local. Otherwise you'll have to pull the plug. – goldilocks Nov 7 '14 at 20:11
  • The process would likely actually be the name of the script that's in /etc/rc.local/; you want to kill that. – DopeGhoti Nov 7 '14 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.