Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 4058  / 1 Year ago, tue, january 17, 2023, 1:47:19

I am trying to hibernate from cron using the command systemctl hibernate. However, I am getting the following error:



Failed to set wall message, ignoring: Interactive authentication required.
Failed to hibernate system via logind: Interactive authentication required.
Failed to start hibernate.target: Interactive authentication required.
See system logs and 'systemctl status hibernate.target' for details.


If I execute the above command manually from terminal, it works as expected.



How do I hibernate from cron?



I am using Ubuntu 16.04.


More From » 16.04

 Answers
6

This is happening because it needs root privileges.

The solution is to add the hibernate command using sudo crontab -e -u root instead of crontab -e.




polkit is necessary for power management as an unprivileged user. If
you are in a local systemd-logind user session and no other session is
active, the following commands will work without root privileges. If
not (for example, because another user is logged into a tty), systemd
will automatically ask you for the root password.




Power management commands:



systemctl reboot|poweroff|suspend|hibernate|hybrid-sleep


Reference: https://wiki.archlinux.org/index.php/Systemd#Power_management


[#14878] Tuesday, January 17, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulerio

Total Points: 172
Total Questions: 124
Total Answers: 109

Location: Hungary
Member since Thu, Aug 6, 2020
4 Years ago
;