Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to know the uptime since the last wake from standby.

The command uptime only shows the difference between current time minus the last startup time.

share|improve this question

4 Answers 4

In /var/log/pm-suspend.log, look for the last line looking like this one:

Sun Dec 16 09:30:31 CET 2012: Awake.

That's your last wakeup time. You can calculate your uptime since then the way Paul suggested.

Periodically your logrotate will "rotate" logs to prevent them from growing too big, so you may find an empty pm-suspend.log file. In this case, just look for the pm-suspend.log.1 file (you may find also other log files named like pm-suspend.log.2.gz and so on; you can examine them using zcat or zless).

share|improve this answer
    
this worked for me –  Prozi Jun 26 at 15:58

What are you using to initiate the standby?

If you can use a script, then after the line

echo -n "standby" > /proc/acpi/sleep

you could have the line

echo `date +%s` >> /var/log/wakeups.log

Or something similar. This would mean that the first thing the machine did when it woke up was to write the current time and date to a log file (n seconds since epoch).

Then tail -1 /var/log/wakeups.log would give you the last time. You could could subtract this from the current time to get seconds since the last wakeup.

share|improve this answer

Search for the last occurence of the string "PM: restore of devices complete" in /var/log/messages. If your machine has been up too long, then the log may be rotated, though.

share|improve this answer

modified better verision of steps answer

grep ': Awake' /var/log/pm-suspend.log

edit haha thanks for the comments :D

share|improve this answer
    
And you won a useless use of cat point! –  gniourf_gniourf Jun 26 at 15:59
    
No upvotes for useless use of 'cat'. –  Magellan Jun 26 at 16:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.