Skip to main content
Fixed typo. Explained that Ubuntu (and probably Debian 8) do it differently.
Source Link

Not fully satisfying

I had a similar need inon a Debian machine7.8 and observe that basically there's no clear and explicit message in log, which is a little surprising.

Grep through /var/log would tell the time the machine was shut down, show proper daemons shutdown, etc, but not the initial reason.

shutdown[25861]: shutting down for system halt 

The other solutions mentioned (last -x) did not help much.

Looking how it works

Reading /etc/acpi/powerbtn-acpi-support.sh which includes:

 if [ -x /etc/acpi/powerbtn.sh ] ; then # Compatibility with old config script from acpid package /etc/acpi/powerbtn.sh elif [ -x /etc/acpi/powerbtn.sh.dpkg-bak ] ; then # Compatibility with old config script from acpid package # which is still around because it was changed by the admin /etc/acpi/powerbtn.sh.dpkg-bak else # Normal handling. /sbin/shutdown -h -P now "Power button pressed" fi 

Notice that an explicit testtext is given as parameter of the shutdown command. I would expect that string to be logged automatically by the shutdown program.

Adjusting for better logs

Anyway, to get an explicit message I put the text below (as root) in a newly created /etc/acpi/powerbtn.sh made executable with chmod a+x /etc/acpi/powerbtn.sh

 #!/bin/sh logger in /etc/acpi/powerbtn.sh, presumably "Power button pressed" /sbin/shutdown -h -P now "Power button pressed" 

Doing it this way will probably make a longer lasting change than modifying /etc/acpi/powerbtn-acpi-support.sh. The latter option would probably lose its effect on next upgrade of package acpi-support-base.

Notice than Ubuntu 14.04 does it differently (/etc/acpi/powerbtn.sh already exists with different content from acpid package). Also, Debian 8 probably does it differently. Feel free to offer variants.

Profit!

And now when the power button is pressed, a line like below appears in /var/log/messages, /var/log/syslog and /var/log/user.log:

logger: in /etc/acpi/powerbtn.sh, presumably Power button pressed 

Now that's an explicit message in the log.

Not fully satisfying

I had a similar need in a Debian machine and observe that basically there's no clear and explicit message in log, which is a little surprising.

Grep through /var/log would tell the time the machine was shut down, show proper daemons shutdown, etc, but not the initial reason.

shutdown[25861]: shutting down for system halt 

The other solutions mentioned (last -x) did not help much.

Looking how it works

Reading /etc/acpi/powerbtn-acpi-support.sh which includes:

 if [ -x /etc/acpi/powerbtn.sh ] ; then # Compatibility with old config script from acpid package /etc/acpi/powerbtn.sh elif [ -x /etc/acpi/powerbtn.sh.dpkg-bak ] ; then # Compatibility with old config script from acpid package # which is still around because it was changed by the admin /etc/acpi/powerbtn.sh.dpkg-bak else # Normal handling. /sbin/shutdown -h -P now "Power button pressed" fi 

Notice that an explicit test is given as parameter of the shutdown command. I would expect that string to be logged automatically by the shutdown program.

Adjusting for better logs

Anyway, to get an explicit message I put the text below (as root) in a newly created /etc/acpi/powerbtn.sh made executable with chmod a+x /etc/acpi/powerbtn.sh

 #!/bin/sh logger in /etc/acpi/powerbtn.sh, presumably "Power button pressed" /sbin/shutdown -h -P now "Power button pressed" 

Profit!

And now when the power button is pressed, a line like below appears in /var/log/messages, /var/log/syslog and /var/log/user.log:

logger: in /etc/acpi/powerbtn.sh, presumably Power button pressed 

Now that's an explicit message in the log.

Not fully satisfying

I had a similar need on a Debian 7.8 and observe that basically there's no clear and explicit message in log, which is a little surprising.

Grep through /var/log would tell the time the machine was shut down, show proper daemons shutdown, etc, but not the initial reason.

shutdown[25861]: shutting down for system halt 

The other solutions mentioned (last -x) did not help much.

Looking how it works

Reading /etc/acpi/powerbtn-acpi-support.sh which includes:

 if [ -x /etc/acpi/powerbtn.sh ] ; then # Compatibility with old config script from acpid package /etc/acpi/powerbtn.sh elif [ -x /etc/acpi/powerbtn.sh.dpkg-bak ] ; then # Compatibility with old config script from acpid package # which is still around because it was changed by the admin /etc/acpi/powerbtn.sh.dpkg-bak else # Normal handling. /sbin/shutdown -h -P now "Power button pressed" fi 

Notice that an explicit text is given as parameter of the shutdown command. I would expect that string to be logged automatically by the shutdown program.

Adjusting for better logs

Anyway, to get an explicit message I put the text below (as root) in a newly created /etc/acpi/powerbtn.sh made executable with chmod a+x /etc/acpi/powerbtn.sh

 #!/bin/sh logger in /etc/acpi/powerbtn.sh, presumably "Power button pressed" /sbin/shutdown -h -P now "Power button pressed" 

Doing it this way will probably make a longer lasting change than modifying /etc/acpi/powerbtn-acpi-support.sh. The latter option would probably lose its effect on next upgrade of package acpi-support-base.

Notice than Ubuntu 14.04 does it differently (/etc/acpi/powerbtn.sh already exists with different content from acpid package). Also, Debian 8 probably does it differently. Feel free to offer variants.

Profit!

And now when the power button is pressed, a line like below appears in /var/log/messages, /var/log/syslog and /var/log/user.log:

logger: in /etc/acpi/powerbtn.sh, presumably Power button pressed 

Now that's an explicit message in the log.

Source Link

Not fully satisfying

I had a similar need in a Debian machine and observe that basically there's no clear and explicit message in log, which is a little surprising.

Grep through /var/log would tell the time the machine was shut down, show proper daemons shutdown, etc, but not the initial reason.

shutdown[25861]: shutting down for system halt 

The other solutions mentioned (last -x) did not help much.

Looking how it works

Reading /etc/acpi/powerbtn-acpi-support.sh which includes:

 if [ -x /etc/acpi/powerbtn.sh ] ; then # Compatibility with old config script from acpid package /etc/acpi/powerbtn.sh elif [ -x /etc/acpi/powerbtn.sh.dpkg-bak ] ; then # Compatibility with old config script from acpid package # which is still around because it was changed by the admin /etc/acpi/powerbtn.sh.dpkg-bak else # Normal handling. /sbin/shutdown -h -P now "Power button pressed" fi 

Notice that an explicit test is given as parameter of the shutdown command. I would expect that string to be logged automatically by the shutdown program.

Adjusting for better logs

Anyway, to get an explicit message I put the text below (as root) in a newly created /etc/acpi/powerbtn.sh made executable with chmod a+x /etc/acpi/powerbtn.sh

 #!/bin/sh logger in /etc/acpi/powerbtn.sh, presumably "Power button pressed" /sbin/shutdown -h -P now "Power button pressed" 

Profit!

And now when the power button is pressed, a line like below appears in /var/log/messages, /var/log/syslog and /var/log/user.log:

logger: in /etc/acpi/powerbtn.sh, presumably Power button pressed 

Now that's an explicit message in the log.