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?

  • Are you sure systemctl or sudo 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. Sep 29, 2018 at 7:31
  • Even in cases where sudo doesn't require a password (tag NOPASSWD), it might still check that there's a, roughly speaking, interactive session (i.e. option requiretty). Defaults on that seem to vary between distros, though, but sudo -l should list the explicitly set options that apply to you. Sep 29, 2018 at 7:59
  • @KamilMaciorowski, yes I'm sure, I checked this out several times. As I had already mentioned - nothing happens, literally nothing.
    – folivore
    Sep 30, 2018 at 17:35
  • @UlrichSchwarz, I'm using Ubuntu though I'm not fond of it. And my user has (ALL : ALL) ALL - default 'sudo' privileges as for Ubuntu distro.
    – folivore
    Sep 30, 2018 at 17:40

1 Answer 1


Policy Kit can apply rules to shutdown and poweroff (which are just the systemctl program by another name) run in non-login-session context as an at job that are different to the rules applied to shutdown run in login-session context.

sudo just over-eggs this pudding, adding unnecessary extra complication. systemd is already applying rules as to which unprivileged users, in which contexts, can successfully trigger a system shutdown. Adding sudo with its additional mechanisms on top of all that just doubles the number of access rulesets and increases the number of possible cases that one has to consider when diagnosing problems.

Further reading

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .