Press Ctrl+Cmd+Q to lock, and keep the Mac awake separately, for example with caffeinate -i in Terminal. Locking on its own doesn't stop anything that is running. Sleep does, and sleep is decided by your Energy settings, not by the lock.

Most people who search for this have had the same morning: they locked the Mac, went home, and found the agent run or the build paused at 10 percent. The lock wasn't the problem. The Mac fell asleep a while after it.

Does locking the screen pause my work?

No. When you lock, your session stays logged in and every app keeps running. Terminal jobs, downloads and coding agents carry on behind the lock screen.

The trouble starts later. After the screen goes dark, the Mac counts as idle, and if your settings allow it, it goes to sleep. Then everything stops until someone wakes it.

How do I lock a Mac?

  • Keyboard: Ctrl+Cmd+Q.
  • Menu: Apple menu → Lock Screen.
  • Hot corner: System Settings → Desktop & Dock → Hot Corners, and set a corner to Lock Screen.

All three do the same thing. None of them changes whether the Mac sleeps.

How do I keep it awake while it is locked?

  • From Terminal. Run caffeinate -i before you lock. It holds off idle sleep until you press Ctrl+C. To tie it to one job, use caffeinate -i your-command or caffeinate -i -w <PID>, and it ends when that job ends.
  • From System Settings. On a desktop Mac, turn on "Prevent automatic sleeping when the display is off" under Energy. On a MacBook, the same switch is under Battery → Options and applies when you are on power.
  • With a menu bar app. A keep-awake app does the same as caffeinate with a button, so you don't have to remember the Terminal window.

To check it worked, run pmset -g assertions. You should see PreventUserIdleSystemSleep set to 1.

What about a MacBook with the lid closed?

Closing the lid puts a MacBook to sleep, whatever the lock or caffeinate says, unless it is on power with an external display, keyboard and mouse attached. For a long run, leave the lid open and let the screen go dark instead.

When the lock screen isn't what you want

The lock screen is the right tool when you need real security. Use it whenever someone could sit down at your desk.

It is less handy when you only step away for a few minutes and want the screen to look off. Anyone who touches the mouse sees your login prompt with your name on it, and you type your full password or use Touch ID every time you come back. If what you want is "the screen looks asleep, the Mac keeps working, I unlock with a short code", that is a different tool.

For that case I use Possum, a fake screensaver we make. It keeps the Mac awake while a cover is up, fades every display to black, and asks for a PIN when someone moves the mouse. It is a curtain, not a lock, so for leaving the desk for the day, Ctrl+Cmd+Q is still the answer.

How do you keep long jobs running when you step away? caffeinate, a settings switch, or something else?