How to Keep Your Mac Awake and Locked Overnight
Keep a Mac running overnight so Dropbox can finish syncing while the screen still locks. Covers the Lock Screen setting, caffeinate and Glowmoth.
GuideUpdated 7 min read
On this page
You want a big Dropbox sync to finish overnight, but a keep-awake app like Caffeine also holds the screen on, so your Mac sits unlocked. Here is how to get "awake and locked" instead.
Why keep-awake apps leave the Mac unlocked
macOS has two separate sleep behaviors: the system sleeping and the display sleeping. Your password prompt is tied to the display or screen saver. Apple's setting is named "Require password after screen saver begins or display is turned off," per Apple's page on requiring a password.
Many keep-awake tools hold the display on as well. If the display never goes idle, the screen saver never starts and the password requirement never triggers. The original Caffeine by Lighthead (discontinued) works this way: it stops the screen from dimming, the screen saver from starting and the Mac from sleeping.
The fix is a keep-awake that blocks only system sleep. The display then goes dark on your normal timer and the lock follows. Locked is not asleep: apps keep running and Dropbox keeps syncing.
Set up the lock first
Do this once, whichever method you pick below.
- Choose Apple menu > System Settings, then click Lock Screen in the sidebar (you may need to scroll).
- Set Require password after screen saver begins or display is turned off to Immediately.
- Set the display-off timers on the same pane to a short time, such as 5 or 10 minutes. There are separate options for battery and power adapter.
Apple documents these options on its Lock Screen settings page. Labels shift slightly between macOS 14, 15 and 26, so if you don't see them, search System Settings for "Lock Screen".
Method 1: the built-in Energy or Battery setting
macOS has an option to prevent automatic sleeping when the display is off. It lives under Energy on desktop Macs and under Battery on MacBooks, where it applies on the power adapter, so plug in. The exact label and location differ between macOS versions, so search System Settings for "prevent automatic sleeping".
With it on, the Mac keeps running after the display turns off, and your password requirement locks it. Pick this if the Mac should stay awake whenever it is plugged in. It has no timer, so remember to turn it off again.
Method 2: caffeinate in Terminal
macOS includes caffeinate. The -i flag blocks idle system sleep without holding the display on.
caffeinate -i -t 28800This keeps the Mac awake for 28,800 seconds (8 hours), then exits. To stop early, press Control-C in that Terminal window or close it. It changes nothing permanently, so there is nothing to undo.
Don't add -d: that holds the display on, which is the behavior you are avoiding. See caffeinate command on Mac for the other flags.
Method 3: Glowmoth with "Keep the display on" off
Glowmoth holds at most one power assertion at a time, in one of two kinds. Display on keeps the screen lit and the Mac awake. System only keeps the Mac awake while the display sleeps as usual. Your own session uses the display kind by default, so you must switch it off.
Set it once for all new sessions
- Right-click the moth icon in the menu bar and choose Settings… (
⌘,). - Open the Sessions tab.
- Under Display, turn off Keep the display on.
- Right-click the moth, choose Until, then 7:00 Tomorrow. The label follows your clock format, so it may read "7:00 AM Tomorrow". For another time choose Other Time…, or use Custom… with a duration such as
8h. - Press
⌃⌘Qto lock the Mac.
Change a session that is already running
You don't need to restart. Right-click the icon and click Keep Display On to remove its checkmark. Or open the panel, expand Show More and turn off Keep Display On. The change applies to the running session.
Confirm it worked
This read-only command lists active power assertions:
pmset -g assertionsLook for an entry named Glowmoth: … under PreventUserIdleSystemSleep. If it appears under PreventUserIdleDisplaySleep, the display is still being held on.
Optional: lock when the session ends
In Settings > Sessions > When a Session Ends, set Then to Lock the Screen. When a timed session runs out on its own, the Mac locks. It does not fire if you stop the session by hand. This is a backup if you left without locking.
Optional: run it every night with a rule
- Open Settings > Automation > Rules, click Add Rule and choose Custom Rule….
- Name it, then use Add Condition to add During Hours. Set the days and a window such as 22:00 to 7:00. Overnight windows are allowed.
- Optionally add On AC Power and keep Keep awake when on All conditions are true.
- Leave Keep the display on off. That is the default for rules.
Rules only work while Keep awake automatically (Settings > Automation) is on, which is the default. Stop Everything pauses them until you next start a session. See automatic rules and display, screen saver and screen lock.
Which method to pick
| Method | Display can sleep (so it locks) | Has a timer | Best for |
|---|---|---|---|
| Energy/Battery setting | Yes | No | Always-plugged-in Macs, no extra app |
caffeinate -i -t | Yes | Yes | One-off nights, comfortable with Terminal |
| Glowmoth, Keep the display on off | Yes | Yes, plus rules | Repeated jobs, a clear view of why the Mac is awake |
| Original Caffeine (discontinued) | No | No | Cases where the screen must stay on |
If you need this only now and then, the built-in setting or caffeinate is enough. For more options, see Caffeine for Mac alternatives.
Checklist before you leave
- Lock Screen requires a password Immediately.
- The display-off timer is not set to Never.
- The Mac is on power, and the lid is open (or you use closed-lid mode, below).
- Glowmoth's Keep Display On has no checkmark, or
pmset -g assertionsshows no display assertion from it. - Dropbox is not paused. Its menu bar icon shows a pause badge if it is, and Dropbox's page on pausing and resuming sync explains how to resume. A manual pause can last until tomorrow or indefinitely.
If it doesn't work
The Mac is still unlocked in the morning
Check the password requirement and the display-off timer first. Then look for something else holding the display on, such as a video or a call. In Glowmoth's panel, expand Show More to see Also Keeping This Mac Awake, which lists other apps holding sleep-blocking assertions and why. Running pmset -g assertions shows the same data. See see what's keeping your Mac awake.
The Mac slept anyway
- Lid closed. A closed MacBook sleeps unless it has power and an external display. Glowmoth has a separate closed-lid mode: see keep a MacBook awake with the lid closed.
- Safety pause. Glowmoth pauses on low battery (below 20% by default) and when macOS reports the Mac running hot. Plug in for overnight runs. See battery and heat safety limits.
- Scheduled sleep or automatic log-out. The panel's explainer flags a scheduled sleep or shutdown and an auto log-out after inactivity. Either can end the night early.
- No valid license. If the trial has ended or the license can't be verified, Glowmoth holds nothing.
The Mac stayed awake but Dropbox did not finish
A running Mac doesn't repair a dropped network, and Glowmoth doesn't keep Wi-Fi or VPN connections alive. Check your connection and the Dropbox app's own status. If you are contacting Dropbox, tell them the Mac was awake and locked, and what its menu bar icon showed.
Still stuck
Contact MacSuite support for Glowmoth problems, or Apple Support for Lock Screen behavior. Include your macOS version, what pmset -g assertions printed, and what you tried.
Subject: Mac sleeps or stays unlocked during a Glowmoth session
macOS version: (your version)
Glowmoth version: (from About Glowmoth)
Session: Until 7:00 Tomorrow, "Keep Display On" turned off
Problem: (the Mac slept at about HH:MM / the screen stayed unlocked)
Output of `pmset -g assertions`: (paste here)
Already tried: Lock Screen set to Immediately, plugged in, checked Show MoreGlowmoth for this job
Glowmoth fits when you do this often. A system-only session blocks idle sleep and leaves the lock to macOS, and Glowmoth has no setting that stops macOS from locking. It is part of MacSuite, and you can try it free for 7 days.
Common questions
Does a locked Mac keep running apps?
Yes. Locking the screen doesn't stop running apps. Only sleep pauses them, which is why you block sleep and allow the lock.
Does Glowmoth lock the Mac for me?
Not during a session. Locking comes from your Lock Screen settings, ⌃⌘Q, or the optional Lock the Screen end action above.
Can I keep the display on while I work, then let it go dark?
Yes. In Settings > Sessions, turn on Let the screen saver start when I'm away. After the idle time you set (10 minutes by default), the display may sleep while the Mac stays awake. If Keep the display on is already off, you don't need it.
Will the sync finish faster if the Mac stays awake?
Staying awake only stops the sync being interrupted by sleep. Speed depends on your connection and Dropbox's own bandwidth settings.