Learn how to automatically shut down your computer using simple commands in Windows and macOS. Discover useful tips and tricks that will allow you to automate the shutdown of your device at any time.
Automating your computer’s shutdown is not only convenient, but also saves energy and gives you more control over how long you work on your device. This solution can be useful in many situations, such as when you leave your device downloading files overnight. In this article, we’ll show you how to configure automatic shutdown on Windows and macOS. With a few simple steps, you can set your computer to shut down at a specific time or after a specific task is completed.
Automatically turn off your computer in Windows
Shutdown command in command line
In Windows there is a command called shutdown
which allows you to shut down, restart, or log off a user from the system. To run this command, simply open the command prompt (cmd) and type the appropriate sequence of commands.
Opening the command line
To open a command prompt:
- Press the key combination
Win + R
to open the Run dialog box. - Enter
cmd
and press Enter.
Shutdown command in practice
Command shutdown
has many parameters that can be used depending on your needs. Here are the basic components:
shutdown /s
– turns off the computer.shutdown /r
– restarts the computer.shutdown /l
– logs the user out.
Examples of using the shutdown command
- To turn off your computer in 60 seconds, type:
shutdown /s /t 60
- To restart your computer in 120 seconds, type:
shutdown /r /t 120
- To cancel a scheduled shutdown, type:
shutdown /a
Shortcut to automatically shutdown your computer
If you often want to turn off your computer automatically, you can create a shortcut on your desktop:
- Right click on the desktop and select
Nowy
>Skrót
. - In the item location field, enter:
shutdown /s /t 60
(or another command of your choice).
- Click
Dalej
give the shortcut a name (e.g. “Turn off computer”) and clickZakończ
.
Automatic shutdown of Apple computer
In macOS, there is also an option to automatically shut down your computer. This can be done via Terminal or system settings.
Automatically shutting down macOS using Terminal
In macOS you can use the command sudo shutdown
to turn off your computer after a specified period of time.
Terminal Opening
To open Terminal:
- Open Finder.
- go to
Aplikacje
>Narzędzia
and startTerminal
.
Mac shutdown command
Basic command syntax shutdown
w macOS to:
sudo shutdown -h +m
Where +m
indicates the time in minutes after which the computer should turn off.
Examples of using the shutdown command
- To turn off your computer in 30 minutes, type:
sudo shutdown -h +30
- To restart your computer in 60 minutes, type:
sudo shutdown -r +60
- To cancel a scheduled shutdown, type:
sudo shutdown -c
Mac power on/off schedule
Scheduling Your Mac to Turn On or Off in Terminal
In macOS, you can set a schedule to automatically turn on, sleep, restart, and shut down your computer using the command pmset
in Terminal. With this feature, your Mac can, for example, turn on by itself before you arrive at work, and then turn itself off when you’re done.
To use this feature, open the Terminal application and enter the command pmset
. By browsing the manual page (man pmset
), you will find a list of available attributes that you can use to configure the schedule. Here are some useful commands:
pmset -g sched
– display the current schedule.sudo pmset repeat wake M 8:00:00
– Create a schedule to wake your Mac every Monday at 8:00 AM.sudo pmset repeat cancel
– canceling the current schedule.
To confirm each command, press the Return key.
Note that the automatic shutdown of the computer will only occur when the Mac is awake and the user is logged in. If the Mac is asleep or the user is not logged in, the computer will not shut down as scheduled. Additionally, if you have FileVault turned on, you will have to log in each time the Mac starts up, which eliminates the possibility of automatic login. It is also worth noting that if you have open documents with unsaved changes, the computer may not go to sleep or shut down as scheduled.
Source: antyweb.pl