I'm trying to schedule shutdown of PC using at command like this:
echo "systemctl poweroff" | at -M now +1 minute
or like this:
echo "sudo systemctl poweroff" | at -M now +1 minute
but nothing happens. Why?
atd
is running and the command below works fine just to check it out:
echo "echo Hello 2>&1 > /home/<user_name>/at-test.txt" | at -M now +1 minute
I know that shutdown can be scheduled using shutdown -P TIME
but please answer my question first instead of pointing out some alternatives.
So what am I doing wrong?
systemctl
orsudo
doesn't try to ask for your password when the time comes? If it does then this won't work because there is no tty available to it, I think. – Kamil Maciorowski Sep 29 '18 at 07:31sudo
doesn't require a password (tagNOPASSWD
), it might still check that there's a, roughly speaking, interactive session (i.e. optionrequiretty
). Defaults on that seem to vary between distros, though, butsudo -l
should list the explicitly set options that apply to you. – Ulrich Schwarz Sep 29 '18 at 07:59