0

Is it possible to set a forced shutdown via terminal? E.g.:

sudo shutdown -P 60

But in a way that:

shutdown -c

A non-sudo-user isn't allowed. That's my problem. A non-sudo-user can cancel the shutdown command.

Or is there another solution or way to achieve the same effect?

6
  • Seems rude to do that to a user. Why is the poweroff more important than another person?
    – user535733
    May 3, 2021 at 13:36
  • If the user has access to the shutdown command, it is difficult to prevent the user from using one of its options. You probably will need to fully disable access to that command for non root users.
    – vanadium
    May 3, 2021 at 14:07
  • @user535733 Have you ever worked on a large multi user linux/unix system where one user tries to avoid an announced reboot / service window ?
    – Soren A
    May 3, 2021 at 14:14
  • 1
    You can schedule the shutdown by at or cron job at the wanted time as shutdown now. Shutdown can't be canceled when argument is now or +0.
    – Soren A
    May 3, 2021 at 14:21
  • @SorenA sure, but an admin is always present for the maintenance to warn and then kick those users. The point is that if no admin will be present, then is the exact timing of the poweroff so important? There may be alternatives.
    – user535733
    May 3, 2021 at 14:45

1 Answer 1

0

Using 'at' to schedule a shutdown at next 11:00 as root

(You might have to install 'at' first: sudo apt install at)

$ sudo at 11:00
[sudo] Password for <user>:
at> shutdown now
at> Ctrl-d

To see root's at-queue:

sudo atq

See man at for other options and parameters.

Cron, as I mentioned too, executes a command at a given time, every time that time happens, like 15 minutes past, every 5. day of the week or combinations of minutes, hours, day, day of week and day of month. This is usefull for commands that have to run at specific times every day, week or month, but not for a onetime command. There at is better.

You must log in to answer this question.

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