Macbooks by default are set up so that they will sleep whenever you close the lid, unless they are plugged into an external monitor, keyboard, and mouse. But, what if you want to close your laptop and run to your friend on the other side of the floor to show him your new running app? What if you are listening to some music? What if you want to download or backup at night? Ever wanted to shut the laptop but didn’t want to stop its processes?
Caffeinate Your Mac!
To begin running the caffeinate command and prevent your Mac from sleeping, open the Terminal located in /Applications/Utilities, then type the following command:
While this command is running, you will be able to close the lid on your Mac and still have OS X and your apps running and performing their tasks just as you would if the lid were to remain open.
Caffeinate Your Mac for a specified length of time
You can also caffeinate your MacBook for a specific length of time.
caffeinate -u -t 2100
With the command above, replace “1800” with the number of seconds that you wish the caffeinated command to run. Running this command as-is will cause your Mac to prevent sleeping for 30 minutes (1800 seconds).
Once starting this command, your Mac will be prevented from sleeping for the set amount of time, and will automatically terminate the caffeinate program afterwards, which will cause your Mac to go to sleep soon thereafter.
Cancel the Caffeine
To make the caffeinate command stop running and return your Mac to normal using either of the methods above, simply return to the command line and press the sequence
Control + C
If you want to explore different options available through caffeinate, just type
This will display a list of additional functions you can access by adding the relevant extensions to you caffeinate command.
To quit the displayed manual just type “
If you close the terminal window that is keeping your Mac awake, the commands being executed will stop! Also, you should avoid keeping your Mac running with the lid closed for long periods whilst inside of a bag or otherwise covered up. Doing so will cause heat to build up and could cause damage to your laptop.
techradar.com (March 2014)