You set up a nightly job in Claude Code, go to bed, and in the morning nothing has run. Usually the schedule was fine. The machine it lived on was asleep, or the session it lived in was gone.
The short answer
Claude Code has three built-in ways to schedule work, plus the old-fashioned one:
- `/loop` and the cron tools run inside one open session. The session and the computer both have to be up at 3am.
- Desktop scheduled tasks run on your computer from the Claude Desktop app. The app has to be open and the computer awake. A run your computer sleeps through is skipped, with one catch-up run when it wakes.
- Cloud scheduled tasks run on Anthropic's cloud, so your laptop can be off. Each run starts from a fresh clone of your GitHub repo, and the minimum interval is one hour.
- cron plus `claude -p` on a machine that stays on. No minimum interval, full access to that machine's files, and you run the machine.
If the job needs files that aren't in a GitHub repo, a database, or a dev server that's already running, you need a computer that's on at night.
Side by side
From Anthropic's scheduling comparison, plus the cron option:
/loop | Desktop task | Cloud task | cron + claude -p | |
|---|---|---|---|---|
| Runs on | Your machine | Your machine | Anthropic's cloud | Your always-on machine |
| Machine must be on | Yes | Yes | No | Yes |
| Open session needed | Yes | No (the app must be open) | No | No |
| Survives a restart | Restored on --resume, with exceptions | Yes | Yes | Yes |
| Local files | Yes | Yes | No, fresh clone | Yes |
| Minimum interval | 1 minute | 1 minute when Claude sets it, 1 hour in the forms | 1 hour | 1 minute |
| Expires | After 7 days | No | No | No |
Option 1: /loop, inside a session
/loop 1h check the nightly build and fix anything that brokeOr ask in plain words: "every night at 2:07, run the test suite and write up failures". What the docs say about how it fires:
- Tasks fire only while Claude Code is running and idle. A task due while Claude is busy waits for the current turn to end.
- Recurring tasks expire 7 days after you create them.
- There is no catch-up. If the laptop slept through five runs, you don't get five runs on wake.
- Hourly and daily tasks start up to 30 minutes late on purpose, to spread out traffic.
Good for: watching a build or a PR while you're nearby. Not for: a laptop that sleeps at night.
Option 2: Desktop scheduled tasks
In the Claude Desktop app, open the Code tab, then Scheduled, then New task, and turn on Only on this computer under Advanced settings. Per the Desktop docs:
- Tasks run only while the app is open and the computer is awake. Settings > This computer > System > Keep computer awake stops idle sleep. Closing the lid still sleeps the laptop.
- If the computer slept through a run, Desktop starts one catch-up run on wake for the most recent missed time, within the last seven days.
- A task in Manual permission mode stalls on the first tool it isn't allowed to use. Click Run now once after creating it and choose "always allow" for each prompt, so later runs don't wait.
The catch-up run is worth planning for. A 2am task can run at 9am if the laptop slept all night. The docs suggest putting the guard in the prompt itself, for example: "Only review today's commits. If it's after 8am, write a short note about what was missed instead."
Option 3: cloud scheduled tasks
/schedule every weeknight at 2am, update dependencies and open a PR if tests passOr create one at claude.ai/code/routines (the earlier name for the feature). Per the cloud task docs:
- Runs on Anthropic's cloud, so it works with your laptop closed. Available on Pro, Max, Team and Enterprise.
- Each run is a fresh cloud session that clones your GitHub repositories. Nothing from last night's run is still running.
- Runs start in auto mode by default, so they mostly don't wait for approvals. An ask rule still prompts, and the run waits for you.
- A five-field cron expression is read in UTC. Pick a time a few minutes past the hour, such as 2:07, because runs scheduled exactly on the hour can start several minutes late.
- Expressions that run more often than once an hour are rejected. Runs count toward your plan's usage.
- It's a research preview, so the limits may change.
Good for: repo work with an end: dependency bumps, docs drift, triage. Not for: anything that needs a running database or files outside the repo.
Option 4: cron and claude -p on a machine that stays on
On a Linux box that's on all night, plain cron works. claude -p runs one prompt and exits, using the login saved on that machine.
7 2 * * * cd ~/project && ~/.local/bin/claude -p "Run the test suite. If anything fails, write what failed and why to nightly-report.md." --permission-mode dontAsk --allowedTools "Bash(npm test *)" "Read" "Edit" --max-turns 30 >> ~/nightly.log 2>&1What each piece is for:
- Full path to `claude`. cron runs with a short PATH. Check yours with
which claude. - `--permission-mode dontAsk`. Anything not pre-approved is denied instead of waiting for a person. At 3am, a prompt nobody answers is the same as a stuck job.
- `--allowedTools`. The exact commands the job may run. Keep it narrow.
- `--max-turns`. A hard stop, so a confused run doesn't go all night.
- A log file. You'll want to know what happened.
For a box that only runs scripts, claude setup-token gives a one-year token for CLAUDE_CODE_OAUTH_TOKEN. It can't start Remote Control sessions, so don't use it on a machine you also want to reach from your phone. Our headless login guide covers both.
Good for: jobs that need the machine's own files and services. Not covered: keeping the machine on, patched and signed in. That's yours.
Before you trust any overnight job
- Usage. Every run counts toward your plan's limits. A loop that wakes often all night can use a lot of your plan before you're up. #102597 is one report of overnight wakes burning usage with little done.
- Prompts that wait. If the job can hit a permission prompt, it will wait until morning. Use
dontAskor allow rules for cron, and a pre-approved Desktop task. Keepgit pushbehind an ask rule unless you really want it unattended. - Branches. Let the job work on its own branch, so a bad night is one
git resetaway. - Output you'll read. A report file, a PR, or a message. Silence in the morning should mean "nothing to do", not "didn't run".
Where Podway fits
The jobs that need your files and running services need a computer that's on at night. A Podway pod is an always-on cloud computer for Claude Code. Your project, database and dev server stay on it, and the project doesn't have to be on GitHub. The pod itself runs 24/7 until you suspend it. A /loop in the pod's session can keep firing at night while the session is running and idle, but a pod restart (an update or a resize) ends it, and missed runs don't catch up. Start the /loop again after a restart, and remember Claude Code's 7-day expiry. For a job that must survive restarts, use the pod's durable scheduler instead of /loop.
Claude runs without permission prompts on a pod, because the pod is its own isolated machine, so a 3am run doesn't sit waiting for a tap. If the agent crashes, Podway restarts it and Remote Control reconnects. Before your Claude login expires, Podway tells you, with a one-click reconnect. You can check results from the Claude app on your phone in the morning.
You need your own Claude Pro or Max plan; Podway doesn't include one. On a Team or Enterprise plan, your org Owner has to enable Remote Control first. Your first pod is free, no card needed, and pods start at $4/month. Start a pod, or read more on the agent computer page.
FAQ
Do Claude Code scheduled tasks run when my laptop is asleep?
/loop tasks and Desktop tasks don't. A Desktop task gets one catch-up run when the laptop wakes. Cloud scheduled tasks do run, because they don't use your laptop at all.
Why did my /loop stop after a week?
Recurring session tasks expire 7 days after creation, by design. Create it again, or use a Desktop or cloud task for a job that should last.
Can a cloud scheduled task use files on my computer?
No. Each run clones your GitHub repositories fresh. Files that aren't in the repo, and anything that was running, aren't there.
Does a scheduled run cost extra?
Not separately. Runs draw from your plan's usage the same way an interactive session does.
Can a scheduled job answer its own permission prompts?
No. Pre-approve what it needs: allow rules, --allowedTools with dontAsk for cron, "always allow" on a Desktop task, or auto mode in the cloud.
Last reviewed October 26, 2026, against Anthropic's Claude Code docs. Spot something out of date? Email support@podway.io and we'll fix it.