How to wake a Mac on a schedule and run jobs at night

By Matyas Rathonyi. Published November 15, 2026. Guides

Run the job from launchd, not cron: Apple's launchd manual says cron skips jobs while the Mac is asleep, while launchd starts a missed calendar job the next time the Mac wakes. To have the Mac awake on time, schedule a wake a few minutes earlier with sudo pmset repeat wakeorpoweron MTWRFSU 02:55:00, and wrap the job in caffeinate -i so idle sleep waits for it; with a MacBook lid closed, you also need something that keeps the closed Mac awake.

cronSkips jobs while the Mac sleeps
launchdRuns a missed job at the next wake
pmset repeatWakes the Mac on a schedule
Lid closedForced sleep; apps cannot prevent it

People ask this as "my Mac slept through its cron jobs" or "any way for my Mac to wake up and run routines at night". This guide is written by Matyas Rathonyi, who makes Clamshell for Mac; Clamshell only comes in at the closed-lid step, and everything before it is built into macOS and free. Every command is quoted from the manual pages on macOS 27.2 or from Apple's pages, read on November 15, 2026. On that Mac I ran pmset -g sched (no events were scheduled) and checked the sample job file below with plutil -lint. I did not schedule a wake or load a job, because both change the Mac's settings.

A night timeline. The Mac sleeps, a scheduled wake at 2:55 wakes it, the job runs from 3:00 while caffeinate holds idle sleep, then the Mac sleeps again. Night jobs z z 2:55 wake 3:00 job z caffeinate -i holds idle sleep
Wake first, then run.pmset wakes the Mac a few minutes early, launchd starts the job on time, and caffeinate keeps idle sleep away until the job exits.

What runs while the Mac is asleep

SchedulerIf the Mac is asleep at the scheduled timeSource
cron (crontab -e)The job is skippedlaunchd.plist(5); crontab(5) adds that cron's work on macOS "has been absorbed into launchd"
launchd, StartCalendarIntervalRuns at the next wake. Several missed times become one runlaunchd.plist(5)
launchd, StartIntervalThat interval is missedlaunchd.plist(5)
Claude Desktop scheduled tasksSkipped. On wake, one catch-up run for the most recent missed time in the last seven daysAnthropic's docs

So neither scheduler wakes the Mac. launchd at least catches up once the Mac is awake again; cron does not. For Codex goals and scheduled tasks, see Does Codex Goal mode keep running with the lid closed?

Step 1: schedule the wake with pmset

Current macOS has no schedule button in System Settings; Apple's page for this is now called Schedule your Mac to turn on or off in Terminal. Reading the schedule needs no password; changing it needs an administrator password.

  1. See what is scheduled now.
    pmset -g sched
    On the Mac this guide was checked on, it printed nothing, which means no events.
  2. Add a daily wake. The manual's types are sleep, wake, poweron, shutdown and wakeorpoweron, and weekdays are letters from MTWRFSU. This wakes the Mac, or starts it if it is off, every day at 2:55:
    sudo pmset repeat wakeorpoweron MTWRFSU 02:55:00
    The manual allows only one pair of repeating events, a power-on event and a power-off event, so check pmset -g sched for an existing one first.
  3. Or wake once. For a single night, give the date in quotes as MM/dd/yy HH:mm:ss:
    sudo pmset schedule wake "11/16/26 02:55:00"
  4. Check it, and know how to remove it. Run pmset -g sched again. sudo pmset repeat cancel removes the repeating schedule.

Apple's page adds two limits: a scheduled shutdown needs the Mac awake and you logged in, and a document with unsaved changes can stop a scheduled sleep or shutdown. And if FileVault is on, Apple says you must log in every time the Mac starts up, which matters if you schedule poweron for a Mac that is shut down. The manual also has pmset relative wake, but says that event "cannot be cancelled and is inherently imprecise".

Step 2: run the job from launchd

A per-user launchd job is a property list in ~/Library/LaunchAgents. This one starts at 3:00 every day and runs your script under caffeinate -i, which the caffeinate manual says holds off idle sleep for as long as the script runs. Replace the script path with yours; it passed plutil -lint.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.example.nightly</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/bin/caffeinate</string>
    <string>-i</string>
    <string>/Users/you/bin/nightly.sh</string>
  </array>
  <key>StartCalendarInterval</key>
  <dict>
    <key>Hour</key>
    <integer>3</integer>
    <key>Minute</key>
    <integer>0</integer>
  </dict>
  <key>StandardOutPath</key>
  <string>/tmp/nightly.log</string>
  <key>StandardErrorPath</key>
  <string>/tmp/nightly.log</string>
</dict>
</plist>
  1. Save it as ~/Library/LaunchAgents/com.example.nightly.plist.
  2. Load it into your user's domain with launchctl's bootstrap subcommand:
    launchctl bootstrap gui/$(id -u) \
      ~/Library/LaunchAgents/com.example.nightly.plist
  3. Check it. launchctl print gui/$(id -u)/com.example.nightly shows its state and last exit status. launchctl bootout with the same arguments as step 2 removes it.

If the Mac is still asleep at 3:00 because the wake did not happen, launchd runs the job when the Mac next wakes, as the table above says. That is the reason to prefer it over cron even with a scheduled wake.

Two rows. cron: the Mac is asleep at 3:00 and the job is skipped. launchd: the Mac is asleep at 3:00, and the job runs when the Mac wakes at 7:00. cron 3:00 skipped launchd 3:00 asleep runs at wake
Same missed time, different outcome. The launchd.plist manual says cron skips a job while the computer is asleep, while launchd starts it the next time the computer wakes.

With the MacBook lid closed

This is where a schedule stops being enough. Apple's developer note QA1340 calls closing the lid forced sleep and says "it is not possible to prevent forced sleep, only delay it", so caffeinate -i in the job does not keep a closed MacBook awake. I found no Apple page on whether a scheduled wake keeps a closed MacBook awake long enough to finish a job, and I did not test it. If the job matters, pick one of these:

Leave the lid open

Free. With the lid open, the scheduled wake, launchd and caffeinate -i above are all you need. Turn the screen brightness down.

Apple's closed-display setup

Free if you have the parts. Apple documents a closed MacBook with an external display only while it is connected to power and an external keyboard and mouse. See does clamshell mode need power.

Clamshell for Mac with Arm on a Schedule

The Arm on a Schedule module arms Clamshell by itself on the days and hours you choose while the Mac is plugged in, so the closed Mac stays awake and launchd or cron jobs run on time. Pick hours that begin while you are still at the open Mac, such as 22:00 to 07:00: it arms at the start time, or when you open the lid during those hours, and then you close the lid. It never wakes a sleeping Mac. At the end time it disarms and the Mac sleeps normally. $9.99 once after a 7-day free trial.

Try it free

For coding agents that stop on a usage limit, Clamshell's optional Sleep Until Reset module works the other way round: on the charger with the lid closed, it lets the Mac sleep once no agent is working and one stopped on a limit, and wakes it 1 minute after each limited Claude Code or Codex account resets. macOS asks you once to allow it in Login Items. The usage limit guide covers that case. sudo pmset -a disablesleep 1 also keeps a closed Mac awake, for every hour of the day until you undo it; read this first.

Scheduled agent tasks

Anthropic's docs for Claude Desktop scheduled tasks are direct about sleep: "Tasks only run while the desktop app is running and your computer is awake. If your computer sleeps through a scheduled time, the run is skipped." When the app starts or the computer wakes, Desktop starts one catch-up run for the most recently missed time in the last seven days, so a 9:00 task can run at 23:00. The docs also note that the app's Keep computer awake setting prevents idle sleep, and "Closing the laptop lid still puts it to sleep." The same rules as above apply: keep the Mac awake through the scheduled time, or expect one late run. More in If I close my laptop, will Claude keep running?

Clamshell keeps your Mac awake with the lid closed, and its Arm on a Schedule module does it only during the hours you choose. Free for 7 days, then $9.99 once for one Mac. 14-day money-back guarantee.

Apple Silicon, macOS 14+. Notarized by Apple. Or install with Homebrew: brew install --cask clamshell. Also on Setapp.

Frequently asked questions

Do cron jobs run when a Mac is asleep?

No. The launchd.plist manual says cron skips job invocations when the computer is asleep. A launchd job with StartCalendarInterval runs the next time the Mac wakes instead, and several missed times become one run.

How do I make my Mac wake up at a certain time?

Use pmset in Terminal; current macOS has no schedule button in System Settings. sudo pmset repeat wakeorpoweron MTWRFSU 02:55:00 wakes or starts the Mac every day at 2:55, pmset -g sched shows the schedule, and sudo pmset repeat cancel removes it.

Will a launchd job run if my Mac was asleep at the scheduled time?

Yes, for StartCalendarInterval: launchd starts the job the next time the Mac wakes, and coalesces several missed times into one run. A StartInterval job misses the interval instead.

Do Claude Desktop scheduled tasks run while my Mac sleeps?

No. Anthropic's docs say tasks only run while the desktop app is running and the computer is awake, and a run the computer sleeps through is skipped. When the computer wakes, Desktop starts one catch-up run for the most recently missed time in the last seven days.

Can I run night jobs with the MacBook lid closed?

Not with caffeinate or a scheduled wake alone: Apple's QA1340 says closing the lid is forced sleep, which apps can delay but not prevent. Use Apple's closed-display setup with power, an external display, keyboard and mouse, or an app that keeps a closed Mac awake. Clamshell for Mac's Arm on a Schedule module arms it during the hours you choose while the Mac is plugged in, so jobs run on time with the lid closed; it never wakes a sleeping Mac.

Related guides

Sources checked November 15, 2026: the launchd.plist(5), launchd(8), launchctl(1), crontab(5), cron(8), pmset(1) and caffeinate(8) manual pages on macOS 27.2; Apple's Schedule your Mac to turn on or off in Terminal; Apple Technical Q&A QA1340; Anthropic's Claude Desktop scheduled tasks docs. Clamshell behavior is described from its module descriptions and published facts. Clamshell is an independent app, not affiliated with or endorsed by Apple or Anthropic. Claude is a trademark of Anthropic.