Solved

How to tell if a Linux machine was hard powered

Posted on 2009-05-08
10
386 Views
Last Modified: 2013-12-16
I have a retail system that needs to be kept up to date and on at all times unless rebooted by admin. How can I tell if an employee shuts down the machine by pressing the power button or umplugging the power cord.I need to know if the shutdown was gracefull or hard.
0
Comment
Question by:atorex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 22

Expert Comment

by:Syed Mutahir Ali
ID: 24339489
You can check all the boot/shutdown logs in /var/log/messages
This link have some good info : http://www.cyberciti.biz/tips/linux-shutdown-command-and-logfile.html
hope this helps
0
 
LVL 3

Expert Comment

by:SalmanZG
ID: 24339515
Simply use the command:uptime
This will tell you since how long the system has been up.

I got so used to this that I created a script for windows too.
0
 

Author Comment

by:atorex
ID: 24339619
mutahir the link you gave me is good, thanks but I need to know
How can I deferenciate between gracefull and hard shutdown
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 9

Expert Comment

by:KrazyRhino
ID: 24339714
atorex... if there was power removed there would be no log entry as it would not have time to write it.
Combined with the uptime command that salman said it should give you your answer.
0
 
LVL 3

Accepted Solution

by:
SalmanZG earned 500 total points
ID: 24339974
My mistake for not understanding your question properly.

One easy option is to put a script at run level 6 (shutdown). This will be executed on normal shutdown / reboot and you can append some info to a log file (e.g. 'last reboot') for later analysis.


0
 
LVL 14

Expert Comment

by:Monis Monther
ID: 24340069
Simply use the command last

This is the output from my laptop, its a  fedora 9 , all linux distros have this command, as you can see it tells you when reboots and poweroff happens

[root@server1 ~]# last
root     pts/0        :0.0             Sat May  9 02:17   still logged in  
root     tty1                          Sat May  9 02:16   still logged in  
reboot   system boot  2.6.25-14.fc9.i6 Sat May  9 02:15          (00:26)    
root     pts/0        :0.0             Fri May  8 17:08 - down   (05:47)    
root     tty1                          Fri May  8 17:06 - down   (05:50)    
reboot   system boot  2.6.25-14.fc9.i6 Fri May  8 17:06          (05:50)    
root     pts/0        :0.0             Sat May  2 18:35 - down   (07:15)    
root     tty1                          Sat May  2 18:34 - down   (07:16)    
reboot   system boot  2.6.25-14.fc9.i6 Sat May  2 18:34          (07:17)    

0
 
LVL 14

Expert Comment

by:Monis Monther
ID: 24340074
Another solution would be to attach a UPS and monitor the UPS logs
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24340091
like small_student suggested, use

last | grep boot
0
 
LVL 19

Expert Comment

by:jools
ID: 24375816
have a lookat `dmidecode` There is a section there that says Wake-Up type, I've only just noticed it so don't know if this is just a "setting" or it is reporting how the system was powered up.

Having said that, I always use the way that ha been mentioned above.


Handle 0x0100, DMI type 1, 25 bytes.
System Information
        Manufacturer: HP
        Product Name: ProLiant DL380 G3
        Version: Not Specified
        Serial Number: BLAHBLAHBLAH
        UUID: Horrible Long string etc.
        Wake-up Type: Power Switch

Open in new window

0
 

Author Closing Comment

by:atorex
ID: 31579607
This looks like the best way to go thanks
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question