How to Schedule a System Reboot Using the shutdown Command in Linux

As a Linux system administrator, you rarely sit in front of the physical server you are managing. You connect remotely via SSH. When performing system maintenance, applying kernel updates, or diagnosing memory leaks, a system reboot is often required.

While you can easily pull the plug instantly, doing so on a production server can lead to data corruption, broken database transactions, and an awful user experience for anyone currently connected to the machine. Instead of rebooting instantly, Linux allows you to schedule a graceful reboot using the shutdown command.

In this guide, you will learn how to safely schedule a reboot, broadcast warning messages to logged-in users, and cancel a pending reboot if circumstances change.

The Basic Reboot Command

The standard tool for restarting a Linux machine is the shutdown command. Because restarting a server drops all connections and halts services, this command requires administrative privileges (using sudo or the root user).

To reboot the system immediately, you append the -r (reboot) flag and specify the time as now:

sudo shutdown -r now

The system will immediately broadcast a termination signal (SIGTERM) to all running processes, giving them a brief moment to save their state, before forcefully killing them (SIGKILL) and restarting the hardware.

Scheduling a Reboot with a Time Delay

If you are managing a server with active users, restarting immediately is bad practice. You should give users time to save their work and close their sessions. You can schedule the reboot by replacing now with a time delay in minutes.

To schedule a reboot in exactly 15 minutes, you use the + symbol followed by the number of minutes:

sudo shutdown -r +15

When you run this command, the terminal will lock up and display a message stating that the system is going down for reboot. You will not be able to type new commands in this specific terminal window until the reboot occurs (or unless you cancel it).

Scheduling a Reboot for a Specific Time

If you want the server to restart during off-peak hours (e.g., 2:00 AM) when traffic is lowest, you do not need to calculate the exact number of minutes. You can specify the exact time using the 24-hour format (HH:MM).

To schedule a reboot for 02:00 AM, run:

sudo shutdown -r 02:00

If it is currently 10:00 AM, the system will wait 16 hours before executing the reboot.

Sending a Custom Warning Message to Users

By default, when you schedule a reboot, Linux will use the wall (Write to All) command to send a generic warning message to the terminal screens of all users currently logged into the server via SSH.

You can append a custom message to the end of the shutdown command to provide context for the reboot, which is highly recommended for production environments.

sudo shutdown -r +30 "Server maintenance: Upgrading the kernel. Save your work and log off."

Every logged-in user will immediately see this message printed on their screen. Linux will then automatically send reminder messages as the countdown approaches zero (usually at 15 minutes, 10 minutes, 5 minutes, and 1 minute remaining).

How to Cancel a Scheduled Reboot

If you schedule a reboot for 2:00 AM but realise at 1:00 AM that you made a mistake or the maintenance window has been cancelled, you can easily abort the pending shutdown.

You must open a new terminal window (or a new SSH session) because the original terminal is likely locked by the pending shutdown command.

Run the shutdown command with the -c (cancel) flag:

sudo shutdown -c

Like the initial command, you can append a custom message to inform users that the reboot has been aborted:

sudo shutdown -c "Maintenance cancelled. The server will remain online."

The system will immediately broadcast the cancellation message, and the server will continue running normally.

By mastering the scheduling features of the shutdown command, you ensure professional, disruption-free system administration that respects the integrity of your data and your users’ active sessions.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.