Can I put Delay before bootup of raspberry pi?


9 posts
by GE0N0VA » Wed Jan 16, 2013 2:22 pm
I am using my Pi as a web server and i noticed that if power goes out and comes back raspberry pi boots up immediately unlike my router and i cannot connect to my pi with ssh this happens when raspberry pi is turned on before my router is running so i wanted to put some kind of a delay to make sure that my router boots first and my pi afterwards
Posts: 11
Joined: Wed Jan 16, 2013 2:16 pm
by jamesh » Wed Jan 16, 2013 2:28 pm
It's probably easier to delay the DHCP request to the router (which is probably where its going wrong) later on in the boot, rather than delay the whole boot. Not sure what the procedure for that is though.
Unemployed software engineer currently specialising in camera drivers and frameworks, but can put mind to most embedded tasks. Got a job in N.Cambridge or surroundings? I'm interested!
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11682
Joined: Sat Jul 30, 2011 7:41 pm
by GE0N0VA » Wed Jan 16, 2013 3:45 pm
That would be solution as well but i don't now how to do that
Posts: 11
Joined: Wed Jan 16, 2013 2:16 pm
by randyks » Wed Jan 16, 2013 4:03 pm
You could add
Code: Select all
sleep 15
into your a start up script. This would would cause the pi to wait 15 secs.
Posts: 6
Joined: Thu Jan 03, 2013 7:17 pm
Location: Andover, Kansas
by necc » Wed Jan 16, 2013 4:16 pm
man dhclient.conf

timeout time ;

The timeout statement determines the amount of time that must pass between the time that the client begins to try to determine its address and the time that it decides that it's not going to be able to contact a server. By default, this timeout is sixty seconds. After the timeout has passed, if there are any static leases defined in the configuration file, or any leases remaining in the lease database that have not yet expired, the client will loop through these leases attempting to validate them, and if it finds one that appears to be valid, it will use that lease's address. If there are no valid static leases or unexpired leases in the lease database, the client will restart the protocol after the defined retry interval.

retry time;

The retry statement determines the time that must pass after the client has determined that there is no DHCP server present before it tries again to contact a DHCP server. By default, this is five minutes.
Posts: 25
Joined: Thu Aug 30, 2012 10:55 pm
by GE0N0VA » Wed Jan 16, 2013 4:26 pm
necc wrote:man dhclient.conf

timeout time ;

The timeout statement determines the amount of time that must pass between the time that the client begins to try to determine its address and the time that it decides that it's not going to be able to contact a server. By default, this timeout is sixty seconds. After the timeout has passed, if there are any static leases defined in the configuration file, or any leases remaining in the lease database that have not yet expired, the client will loop through these leases attempting to validate them, and if it finds one that appears to be valid, it will use that lease's address. If there are no valid static leases or unexpired leases in the lease database, the client will restart the protocol after the defined retry interval.

retry time;

The retry statement determines the time that must pass after the client has determined that there is no DHCP server present before it tries again to contact a DHCP server. By default, this is five minutes.


How can i change the default five minutes?
Posts: 11
Joined: Wed Jan 16, 2013 2:16 pm
by GE0N0VA » Wed Jan 16, 2013 4:28 pm
randyks wrote:You could add
Code: Select all
sleep 15
into your a start up script. This would would cause the pi to wait 15 secs.


I am a real n00b with Linux so how can i do that?
Posts: 11
Joined: Wed Jan 16, 2013 2:16 pm
by necc » Wed Jan 16, 2013 4:41 pm
That sleep would go to /etc/init.d/rc.local I would assume, but depending on the order these are run, and I can't remember the exact order from the top of my head this may or may not work.

The dhcp timeout is set in /etc/dhclient.conf, see what's there and either add or amend the existing entries for timeout and/or retry.
You can set:
timeout 120;

,and it will wait 2 minutes before it resigns, and then 5 minutes to retry, or you could change:

retry 1;
,and it would retry more often.

You could of course modify both values to your likening.
Posts: 25
Joined: Thu Aug 30, 2012 10:55 pm
by GE0N0VA » Wed Jan 16, 2013 4:53 pm
Thanks for replies i will try this ASAP
Posts: 11
Joined: Wed Jan 16, 2013 2:16 pm