To prevent your Mac from sleeping from the command line Terminal application, you can use the pmset
command with the displaysleep
and sleep
options. This will disable the automatic sleep and display sleep functions, respectively, which will prevent your Mac from going to sleep.
To disable the automatic sleep function, you can run the following command:
pmset -a displaysleep 0
This will set the display sleep timer to 0 minutes, which will prevent your Mac's display from going to sleep.
To disable the automatic sleep function, you can run the following command:
pmset -a sleep 0
This will set the sleep timer to 0 minutes, which will prevent your Mac from going to sleep.
To make the changes persistent across reboots, you can use the -b
flag with the pmset
command. For example, to disable the automatic sleep and display sleep functions, you can run the following commands:
pmset -b displaysleep 0 pmset -b sleep 0
By using the pmset
command with the displaysleep
and sleep
options, you can easily prevent your Mac from sleeping from the command line Terminal application. This can be useful when running long tasks or processes that you don't want to be interrupted by the Mac going to sleep. It's important to note that disabling the sleep functions can have an impact on the battery life of your Mac, so you should only do this when necessary.