I'd like to suspend my laptop using at
:
echo "systemctl suspend" | at now + 5 minutes
Suspension does not happen, instead I find a mail from at
in /var/spool/mail/me
:
Failed to set wall message, ignoring: Interactive authentication required.
Failed to suspend system via logind: Interactive authentication required.
Failed to start suspend.target: Interactive authentication required.
See system logs and 'systemctl status suspend.target' for details.
Alright, logind
requires authentication when at
runs systemctl suspend
. This is interesting since when I run systemctl suspend
directly, without at
, no authentication is required and the machine goes into suspension.
I've made sure that the commands executed with at
are run by the same non-root user as the commands run directly using echo "echo $(who) > who.txt" | at now
.
Suspecting that authentication is required in at
because it runs the commands via /bin/sh
(which is an alias for bash), I executed systemctl suspend
after starting /bin/sh
: Suspending happens immediately without authentication, indicating that the nested shell is not the reason why suspending fails when done with at
.
I get the same behavior and very similar mails when doing echo "reboot" | at now
and echo "shutdown now" | at now
.
My question is: How does logind
figure out that it's at
that tries to suspend, reboot, or shut down the machine and how can I tell logind
that it should allow at
to execute those commands without authentication?
I'm on Arch Linux 4.18.1 with at
version 3.1.19.
echo 'echo $(who) > who.txt' | at now
? I think $(who) will be evaluated by the shell otherwise. – stefan0xC Aug 26 '18 at 16:48echo 'echo $(who) > who.txt' | at now
writesme tty1 2018-08-26 13:13
to the file. – Matthias Braun Aug 26 '18 at 17:16