Unexpected shutdown


9 posts
by tobiz » Mon Apr 15, 2013 10:02 am
My Raspberry Pi seems to shut down on its own for no reason. It's run headless and I need it to run 24/7. Since it's headless the only way I can find out if it's working is by ping; there's no response. Also the router to which it's connected shows no connection. As I can remember the OS is Raspian, from the log the Linux version is 3.6.11. Is there a config option or something to control shutdown? There is no issue with the power supply or the power being switched off.
Posts: 11
Joined: Tue Mar 20, 2012 2:18 pm
by DeeJay » Mon Apr 15, 2013 10:56 am
Can't answer from direct experience, but some thoughts that might help...

Other people have recently posted uptimes measured in weeks or months, so there is nothing to suggest that a Pi has to shut down from time to time.

The
shutdown
command can take an argument to shutdown sometime in the future, but that's the opposite of what you want - you would know if you had issued a deferred shut down.

Is there anything in the system log that helps - view it with
dmesg
.
(perhaps running a tail on dmesg from the remote console would reveal what happens just before the incident?)

Do you know for sure that the Pi is shutting down? Might it just be losing its network connection? Could the lease time on its IP address be expired by the router?
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
User avatar
Posts: 2033
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK
by tobiz » Mon Apr 15, 2013 11:50 am
Some good ideas here. I recently moved the network connection from my 24-port switch to the ADSL router (the router is connected to the switch by a 1Gb uplink). Not sure whether the problem started after the change but worth investigating. Also not sure why the change would be the cause since the router is the DHCP server and I've not had problems with any other device connected to it or the switch (including another Raspi). I thought normally lease time was set by the client so how can this be viewed or set on the Raspi; most Linux distributions have a simple gui for this. If the Raspi has one what's it called?
Re dmesg: I've looked at the syslog files for today and yesterday's and at the moment can't see anything too unusual but will see what happens today and tomorrow (especially after trying the network change).
Posts: 11
Joined: Tue Mar 20, 2012 2:18 pm
by DeeJay » Mon Apr 15, 2013 11:58 am
tobiz wrote: I thought normally lease time was set by the client


I'd encourage you to check that - I think it's an attribute controlled by the dhcp server. (If otherwise, everyone would ask for an infinite lease, and the network operator would have no control.)
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
User avatar
Posts: 2033
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK
by tobiz » Mon Apr 15, 2013 1:26 pm
Ok, I've checked and the default LAN DHCP leasetime is 72hr. I'm not sure I've seen the network drop out after this time but it could be the case; I'll check. Since the Raspi is headless the only way of seeing what's happening is via a network connection and I can see the network has dropped out but of course don't know if the Raspi is running. On my Draytek router it 's possible to bind a MAC to an IP, most of my connections are so configured. I recall I recently changed the Raspi's MAC to be not so bound. It also looks as if a bound MAC has an unlimited lease time (not sure about this but my other Raspi has not had a network timeout and has been running for several weeks). I'll investigate all this but it looks a promising answer. Thanks
Posts: 11
Joined: Tue Mar 20, 2012 2:18 pm
by tobiz » Thu Apr 18, 2013 8:03 am
My Pi has now been running for over 72hrs and not been detached from the router. I conclude that the DHCP lease time was the issue and on the Draytek 2820 by binding a MAC to an IP it effectively changes the default (gobal) lease time to unlimited (I didn't know this nor can I find it documented anywhere, at the moment). The problem I had was therefore nothing to do with the Pi but the network config on the router. Thanks DeeJay for the pointer, most useful
Posts: 11
Joined: Tue Mar 20, 2012 2:18 pm
by Aydan » Thu Apr 18, 2013 11:13 am
tobiz wrote:My Pi has now been running for over 72hrs and not been detached from the router. I conclude that the DHCP lease time was the issue and on the Draytek 2820 by binding a MAC to an IP it effectively changes the default (gobal) lease time to unlimited (I didn't know this nor can I find it documented anywhere, at the moment). The problem I had was therefore nothing to do with the Pi but the network config on the router. Thanks DeeJay for the pointer, most useful

Shouldn't the DHCP client request a lease extension before the lease expires?
It's been a while since I've read up on DHCP

Regards
Aydan
Posts: 244
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, Lake Constance
by BLL » Thu Oct 09, 2014 1:13 pm
Hi,
Reading this thread, it tallies with the problem I am now getting with my pi, which is now connected to a 5 GHz Receiver unit for wifi and this device is acting as the dhcp device. The Pi keeps shutting down. Just before it does so, you see "sudo halt" ppear on the console screen and it does just that. Nothing I am running is doing that. It has only started hapenng since using this receiver and during boot, it says the lease will be renewed in 400 seconds, which seems very short and appears to coincide with the shutdowns.
I don't know how to proceed any further as I am quite new to all this.
Can anyone help me please?
Thanks
Posts: 71
Joined: Fri Jun 07, 2013 2:30 pm
by DougieLawson » Thu Oct 09, 2014 1:34 pm
Aydan wrote:Shouldn't the DHCP client request a lease extension before the lease expires?


It happens when the lease expires, not before. That's why isc-dhcp-client (or dhcpcd) has to keep running, it wakes up periodically to check the lease expiry time.

The DHCP server will normally renew a lease with identical parms. The incoming request is "can I renew this lease" (for an old client) rather than "can I have a new lease" (which is what happens for a new client).

I always replace isc-dhcp-client with dhcpcd as I found an annoying bug with the isc version and looking at the isc code made me hungry for a plate of spaghetti.
Hacker on ZX80, Microtan65, Raspberry Pis and Arduinos
Unemployed mainframe database troubleshooter
RPi owner since 2012.
Twitter: @DougieLawson

Gaffer tape is "The Force", it has a dark side and a light side and it holds the Universe together.
User avatar
Posts: 7104
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK