Tuesday, 27 July 2010

Linux Shutdown / Login Issues

I frequently use the shutdown command with a time delay to act as a basic 'sleep' function so I can listen to music before I fall asleep. Last night I scheduled a shutdown for 20min but 18min in I prematurely shutdown the computer, without cancelling the scheduled shutdown process. When I booted up the computer the next day I was unable to login despite using correct details: 'Authentication Failure'. I was also prevented from shutting down the system from the login screen. I switched to a different screen (tty2 etc.) and logged in as root after which I was presented with a message that the system was to shutdown in 2min. Attempts to cancel the shutdown using:

% shutdown -c


...didn't work as it couldn't identify the process id to cancel. Logging out and in again a few minutes later revealed the same 2min message. Unsure what to do I read the shutdown man page which revealed that during the last 5min of scheduled shutdown, logins are prevented. This explained the symptoms. I searched the process list but there was no trace of the shutdown utility running. Googling the symptoms revealed nothing so I tried scheduling a(nother) restart (from within root terminal) with a delay of 0min to see if this would clean up / overwrite any left over/corrupt system files:

% shutdown -r now


Fortunately, this worked. I couldn't find evidence of anyone else encountering this problem, so I figured I'd note down the solution here. Essentially I've learned that if you set up a scheduled shutdown, its safest to cancel it explicitly using the shutdown -c command, instead of hoping it will cancel itself when you pull the power.