Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #228978

Executing 'systemctl poweroff' from script run by cron.

From "Juan R. de Silva" <juan.r.d.silva@gmail.com>
Newsgroups linux.debian.user
Subject Executing 'systemctl poweroff' from script run by cron.
Date 2020-11-24 00:00 +0100
Message-ID <BesYt-3io-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


I am running Buster after fairly deafult installation. One of my scripts 
executes '/usr/bin/systemctl poweroff' command. And I am having trouble 
executing this script from cron.

1. If run from user's CLI, the script succeeds.
2. If run from root crontab the script succeeds.
3. If run from user's crontab it fails with the following errors:

"Failed to set wall message, ignoring: Interactive authentication 
required.
Failed to power off system via logind: Interactive authentication 
required.
Failed to start poweroff.target: Interactive authentication required."

1. Why, when the script is run by the user cron job, the execution 
requires authentication, while run from the same user terminal, it does 
not.

2. Is there a way to get rid of this behaviour, since I prefer the script 
being executed by the user's cron job?

3. I am also surprised that 'systemctl poweroff' command can be executed 
either directly from the user's terminal or by running a script without 
any authentication request. There's certain inconsistency here, isn't it? 
IMHO, it does not feel like a safe approach.

Thanks.

Back to linux.debian.user | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Executing 'systemctl poweroff' from script run by cron. "Juan R. de Silva" <juan.r.d.silva@gmail.com> - 2020-11-24 00:00 +0100
  Re: Executing 'systemctl poweroff' from script run by cron. Reco <recoverym4n@enotuniq.net> - 2020-11-24 07:40 +0100
    Re: Executing 'systemctl poweroff' from script run by cron. <tomas@tuxteam.de> - 2020-11-24 10:10 +0100
      Re: Executing 'systemctl poweroff' from script run by cron. Reco <recoverym4n@enotuniq.net> - 2020-11-24 12:00 +0100
        Re: Executing 'systemctl poweroff' from script run by cron. Nicholas Geovanis <nickgeovanis@gmail.com> - 2020-11-24 13:10 +0100
          Re: Executing 'systemctl poweroff' from script run by cron. <tomas@tuxteam.de> - 2020-11-24 13:20 +0100
          Re: Executing 'systemctl poweroff' from script run by cron. Fred <fred@blakemfg.com> - 2020-11-24 15:00 +0100

csiph-web