Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

Before You Shut Down a Remote Server

Warning: after a shutdown, the server is off and SSH no longer answers. You can only start it again from your provider's control panel. In most cases, such as after a kernel update or a configuration change, a restart is what you want. For that, read how to reboot a Linux server or use shutdown -r, shown below.

  • Check who is logged in: who lists other sessions.
  • Let running work finish: backups, database imports, and package upgrades.
  • Take a snapshot before planned work on the system. See snapshot vs backup.

Shut Down Now

sudo shutdown -h now

systemd stops services in order, writes pending data to disk, unmounts filesystems, and powers the machine off. These do the same:

sudo shutdown now
sudo poweroff
sudo systemctl poweroff

Schedule a Shutdown

CommandWhen
sudo shutdown -h +10In 10 minutes.
sudo shutdown -h 22:30At 22:30 server time.
sudo shutdownIn one minute.

With no time given, shutdown waits one minute. A time like 22:30 uses the server's clock; check it with date, because the server may run in a different time zone than you. Five minutes before a scheduled shutdown, systemd creates /run/nologin, and new logins are refused.

Cancel a Scheduled Shutdown

sudo shutdown -c

This cancels a pending shutdown or reboot that was scheduled with a time argument, such as +10 or 22:30.

Reboot Instead

sudo shutdown -r now
sudo shutdown -r +5

-r restarts the server instead of leaving it off. All the timing options above work the same way, and shutdown -c cancels a scheduled reboot too.

Warn Logged-In Users

Text after the time is sent to every terminal:

sudo shutdown -h +15 "Maintenance: the server goes down in 15 minutes"

To send a message without shutting down, use wall "text". sudo shutdown -k +15 sends the usual shutdown warning but does not shut anything down, which is useful for a test.

shutdown, poweroff, halt, and reboot

CommandResult
shutdown -hPowers off, now or later.
poweroffPowers off now.
haltStops the system; power may stay on.
rebootRestarts now.

On current distributions these are all front ends to systemd. Avoid halt on a remote server: the machine stops but may not switch off, and it still has to be reset from the control panel.

Starting the Server Again

Log in to your provider's control panel and use the start or power-on action for the server. If it does not come up, open the console there to see the boot messages. For a dedicated server, the same panel or the server's management interface powers it on; the difference between the two server types is covered in VPS vs dedicated server.

A hard power-off from the panel is the same as pulling the plug. Use it only when the system no longer responds, because unsaved data can be lost.

If the Command Fails

  • Must be root: run it with sudo.
  • A service blocks the shutdown: systemd waits for it up to a time limit, then stops it. Check which one with systemctl list-jobs from a second session.
  • Services missing after start: they were not enabled for boot; see how to list services with systemctl.
Was this answer helpful?
Loading...