Hi All,
I want to stop a service when the system is powered off.
To achieve this, i have done the following:
- Set HandlePowerKey=ignore in /etc/systemd/logind.conf
- Installed acpid package
- Add the 'systemctl stop test.service' command in the /etc/acpi/actions/power.sh script
that is defined as a action for poweroff event in /etc/acpi/events/powerconf config.
I don't see any systemd message for stopping test.service when the system is powered off.
Could you help me to fix this? I would appreciate your help here.
BTW, If i remove the systemctl command from power.sh,
then i see the power-off event is detected by acpid.
Apr 20 02:47:23 test-vm acpid: received input layer event "button/power PBTN 00000080 00000000"
Apr 20 02:47:23 test-vm systemd-logind[431]: Power key pressed.
Apr 20 02:47:23 test-vm acpid: rule from /etc/acpi/events/powerconf matched
Apr 20 02:47:23 test-vm acpid: executing action "/etc/acpi/actions/power.sh"
But, if the systemctl command is present in power.sh, then acpid don't even log these event messages.
# more /etc/system-release
CentOS Linux release 7.4.1708 (Core)
#
# rpm -qa | grep kernel
kernel-3.10.0-693.21.1.el7.x86_64
#
# rpm -qa | grep acpid
acpid-2.0.19-8.el7.x86_64
Thanks,
-karthi
To stop a service when the system is powered off
-
- Posts: 1
- Joined: 2018/04/20 03:15:00