LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-19-2005, 04:34 PM   #1
tukaaa
LQ Newbie
 
Registered: Nov 2005
Posts: 2

Rep: Reputation: 0
Distinguish between crash and reboot


Hello everybody. I'm doing some kind of work where I need to determine from an external point of view if a machine crashed or rebooted: to explain what I mean I'll give you an example. Let's say that there's a computer in a room connected to the network; I can access that computer from the network but I can't enter the room where the computer is. Now: there's a man in the room who can crash the computer (for example by unplugging the power cable) or just reboot it.

To figure out an answer to this question, I was thinking about the behavior of fsck at the very beginning of the startup process: that program knows in some way if the disks were properly or unproperly unmounted. Where does he gather that information from? And: is there any way I can access that information when the machine is booted and ready, or does fsck "delete" that information? Or do you have any other suggestion to solve the same problem?

Thanks to anybody for reading.
Luca
 
Old 11-20-2005, 06:08 AM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,513

Rep: Reputation: Disabled
The information fsck reads is stored outside of filesystem. Think of it as one bit which is set when partition is mounted and unset when unmounted. Clearly not useful for you.
Try reading /var/log/messages.
 
Old 11-20-2005, 03:10 PM   #3
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 86
Reboots are intentional, crashes aren't. Unless a person deliberately chose to reboot the machine in question, it was a crash. I'd agree with Emerson that a useful first place to look would be /var/log/messages
 
Old 11-21-2005, 10:42 PM   #4
ahedler
Member
 
Registered: Oct 2005
Location: A safe distance from Detroit
Distribution: SuSE 10.0, Knoppix
Posts: 99

Rep: Reputation: 17
Basically, if you look at /var/log/messages, you will see startup code every time the machine boots, whether it was a crash or a reboot, but you will only see shutdown code for intentional reboots. You can sometimes infer crashes from boot messages, but the real giveaway is seeing Kxx scripts running from the rc directories; these are run during a shutdown to kill processes. To see what scripts I'm talking about, check /etc/init.d/rc2.d (this path may vary slightly) for instance, there are Kxx scripts and Sxx scripts. The S scripts are for startup, and the K scripts are for shutdown. They are usually links that point at files in /etc/init.d and the same script is used for startup and shutdown of a subsystem, but the S script gets a 'start' parameter added to it, and the K script gets a 'stop' parameter.

Hope this answers your question.

-Alan
 
Old 11-26-2005, 06:25 PM   #5
tukaaa
LQ Newbie
 
Registered: Nov 2005
Posts: 2

Original Poster
Rep: Reputation: 0
thanks guys for your answer. I'd like to know if there's a different solution, though: I mean one that doesn't use log files, or uses log files that are accessible by everybody. The problem is still the same: determine if the last boot was a reboot/shutdown or a crash. I was wondering if reading dmesg and looking for some string can be a decent solution.

thanks

Luca
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Router Crash, no reboot nde Linux - Networking 3 10-06-2005 03:09 PM
Random crash after shutdown or reboot? qwaven SUSE / openSUSE 4 05-13-2005 02:04 AM
Serious crash, problem reboot 2.6.7 kernel reiserfs robtheJobNorflk Slackware 0 10-16-2004 10:06 AM
XFree86 crash forces cold reboot Sonderblade Linux - Software 5 05-30-2004 02:39 PM
Crash/reboot in windows manager (KDE, Gnome) zollies Linux - General 9 07-28-2003 10:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration