Shutdown your computer

On OpenBSD you have the shutdown (/sbin/shutdown) utility available to shutdown your computer or laptop. The basic usage is very simple. You specify how you want to shutdown your computer followed by when and close with an optional message for all users who are still working on the machine.

You have to be root to use shutdown or you have to configure doas to allow other users to use it as well.

For example, to immediately shutdown your computer you have to use the following command.

# shutdown -ph now

The -h flag tells shutdown to halt the system and the -p flag tells it to power down (cut the power). If you don't add the -p flag the system will shutdown but don't cut the power. This is different than on most Linux implementations of shutdown because on OpenBSD the -p flag is not implied by default.

Shutdown in the future

Its also possible to shutdown your computer automatically at some point in the future. You do that by replacing the word "now" with a time value. You have two options there:

  1. You can specify the amount of minutes from now (+minutes)
  2. You can specify a specific date in the future (yymmddhhmm)

You can use the following command to shutdown the computer in exactly 60 minutes from now.

# shutdown -ph +60
Shutdown at Tue Sep 13 18:02:33 2016.
shutdown: [pid 21057]

If you want to shutdown your system at the 13. May 2020 at 13:37 you can use the following command:

# shutdown -ph 2005131337
Shutdown at Wed May 13 13:37:00 2020.
shutdown: [pid 71240]

Cancel a shutdown

You can also cancel an issued shutdown. Maybe you noticed it in the commands above, but you always get a PID for every issued shutdown command. If you want to canel a shutdown you simply have to kill that process.

# kill 71240

If you dont remember the PID you can always search for it in top or via ps.

# ps ax | grep shutdown 
57840 ??  I<sp    0:00.00 shutdown -ph 2005131337
26622 p3  R+      0:00.00 grep shutdown

# kill 57840