0

Say I want my machine to reboot tomorrow at 02:00 am. And not again later, just that one time tomorrow morning. How can I do this?

birgersp
  • 441
  • 1
  • 7
  • 19

1 Answers1

4

Use shutdown -r with TIME option:

$ shutdown -r 02:00
Shutdown scheduled for Fri 2022-04-22 02:00:00 CEST, use 'shutdown -c' to cancel.

From man shutdown:

SYNOPSIS  
  shutdown [OPTIONS...] [TIME] [WALL...]

DESCRIPTION
[...] The time string may either be in the format "hh:mm" [...] specified in 24h clock format. Alternatively it may be in the syntax "+m" referring to the specified number of minutes m from now.

OPTIONS
[...]
-r, --reboot Reboot the machine


Alternatively you can use at to schedule a program execution:

$ echo "reboot -f" | at 02:00
warning: commands will be executed using /bin/sh
job 1 at Fri Apr 22 02:00:00 2022

See list of scheduled commands along with its id using atq, remove from list with atrm <id>.

(may need to install sudo apt install at).


Note: at has the benefit that the schedule survives reboots, while the scheduled shutdown will be canceled when rebooting before 02:00.

pLumo
  • 26,947