Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 need to be able to log the times that an Ubuntu 10.04 Desktop system is suspended and resumed.

I can detect when the system is resumed via a DBus signal (org.freedesktop.UPower.Resuming()) but the corresponding "org.freedesktop.UPower.Sleeping()" signal is never fired. Ideally, I'd like to use DBus, but given the lack of success I'm having, I'd be happy with any solution providing it can be called from the command line.

I've discovered one way to do it:

tail -f /var/log/pm-suspend.log | grep "performing suspend"

This simply listens on one of the pm logs for the suspend logging. Although this works, it's probably rather brittle. I've found relying on log parsing to be rather problematic in the past due to changes in the log statements.

Ideally I'd like a more robust mechanism. The service that invokes this will be ran as root.

share|improve this question
up vote 7 down vote accepted

Try putting the following in /etc/pm/sleep.d. This should be independent of whether your machine uses APM or ACPI.



case "$1" in
                echo "Resumed from suspend at `date`" >> "$LOGFILE"
                echo "Resumed from hibernation at `date`" >> "$LOGFILE"
                echo "Suspended to ram at `date`" >> "$LOGFILE"
                echo "Hibernated to disk at `date`" >> "$LOGFILE"
share|improve this answer

You can drop a script in /etc/apm/suspend.d. It should be executed every time the machine suspends.

You can also use /etc/apm/resume.d in a similar fashion to run a script when it wakes up.

share|improve this answer
Thanks for the answer, It seems like I don't have apm support in my kernel. I see "No APM support in kernel" when i run the command "apm". I know that I can enable this in the kernel for my machine. However, I need to run my program on other machines on which I won't be able to make this change so I don't think APM is going to work :-( – Paul Robinson Oct 18 '10 at 14:50

Your Answer


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.