Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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 '14 at 15:58
What if pm-suspend.log is empty? :( – Cyprian Guerra Oct 27 '15 at 12:50

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 '14 at 15:59
No upvotes for useless use of 'cat'. – Magellan Jun 26 '14 at 16:01

I did not have pm-suspend.log on my machine.

This worked for me:

/usr/bin/pmset -g log | grep Wake | grep "due to" | tail -n1

Also says what woke the computer up. :-)

share|improve this answer
What if there's no command pmset found and no such file as pmset and pm-suspend.log is empty? :( – Cyprian Guerra Oct 27 '15 at 12:51
pm-suspend.log was missing and this works for me (on my iMac) – dayuloli May 7 at 13:05

For desktops/servers running systemd, while there is no direct command that will tell the info directly (as far as I am aware), all the data is captured in the journal.

You can grep the journal, for example:

echo ">> [SUSPEND] Times during current boot"
journalctl -b 0 |grep "]: Suspending system..."
echo ">> [WAKE] Times during current boot"
journalctl -b 0 |grep "PM: Finishing wakeup"

Or, for fancy output, I wrote a python3 script (runs fine on Fedora 23) Sample output:

Initial Boot Timestamp:  2016-01-15 09:31:32 

     Wake Timestamp     |    Suspend Timestamp   |       Awake Time       |
  --------------------  |  --------------------  |  --------------------  |
   2016-01-15 09:31:32  |   2016-01-15 09:36:03  |          0h  4m        |
   2016-01-15 09:36:22  |   2016-01-15 19:15:04  |          9h 38m        |
   2016-01-15 19:22:21  |   2016-01-15 20:00:05  |          0h 37m        |
   -------------------  |  --------------------  |  --------------------  | 

Summary: Days Since Boot [8.23] | Days Awake [4.14] | Suspend/Wake Cycles: [28]

The script is in github. link to github repo

share|improve this answer
This worked for me on Ubuntu 16.04 – raphinesse May 10 at 12:46

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

You can use tuptime for track the system startup/shutdown life.

share|improve this answer
Does not provide the information the OP requested. – wieczorek1990 Jun 24 at 8:39

Extending Steps answer:

grep Awake /var/log/pm-suspend.log | tail -1

This will get the line with the last wakeup time.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .