What are the options for running Claude Code on a schedule?
Five shapes, as of November 2026. They differ in where the run lives, what has to stay switched on, and whether a person can sign off part way through.
The /loop command inside a session is the lightest one, and Anthropic's docs are clear about its reach: tasks fire only while Claude Code is running and idle, closing the terminal stops them, and a recurring task expires after seven days. For work that must happen with nobody at a keyboard, the same docs point to cloud scheduled tasks, a GitHub Actions schedule trigger or Desktop scheduled tasks.
| Option | Where it runs | What must stay on | Sign-off mid-run |
|---|---|---|---|
| /loop in a session | Your open session | The machine and the session | In the live session only |
| cron or a timer with claude -p | A machine or server you keep | That machine | No. A call that needs approval is denied |
| CI schedule (GitHub Actions) | Your CI runners | Nothing of yours | Only between jobs |
| Claude Code cloud scheduled tasks, formerly Routines (research preview) | Anthropic cloud or a self-hosted environment | Nothing of yours. Smallest interval is one hour | Not as a step. The session starts in auto mode where available and asks on an ask rule or after repeated blocks |
| ConvOps schedule | ConvOps Cloud or your own runners | Nothing of yours on ConvOps Cloud | Yes. A gate holds the step until an explicit approval is given |
sourcesClaude Code docs: run prompts on a scheduleClaude Code docs: scheduled tasks in the cloud (formerly Routines)Claude Code docs: GitHub ActionsClaude Code docs: headless mode
How do I run Claude Code from cron or CI?
Write the job once as a script, then let cron or a CI schedule start it. Claude Code in headless mode prints its result and exits 0 on success and non-zero on failure, so any scheduler can tell whether the run worked.
The example is a weekly digest of support tickets kept as files in a repository. The same shape fits a Monday pipeline report for sales, a month-end checklist for finance or a stale-page check for a content team.
- 1
Write a prompt that stands alone
Nobody is there to answer a question, so the prompt names the input, the output and what done looks like. Keep it in a file under version control.
- 2
Give the run a credential
Use an Anthropic API key in ANTHROPIC_API_KEY, or run claude setup-token once and store the long-lived token it prints as CLAUDE_CODE_OAUTH_TOKEN. Keep either one in a secret store, not in the script or the image.
- 3
Write the run script
Allow tools by name, deny everything else, and cap turns and spend. The numbers are placeholders to size from your own attended runs.
#!/usr/bin/env bash # weekly-digest.sh: one scheduled Claude Code run set -euo pipefail cd /srv/support-digest # The credential comes from your secret store, never from the script. claude -p "$(cat prompts/weekly-digest.md)" \ --allowedTools "Read,Grep,Glob,Write" \ --permission-mode dontAsk \ --max-turns 40 \ --max-budget-usd 5 \ --output-format json > "runs/$(date +%F).json" - 4
Schedule it with cron
This line runs every Monday at 07:00 in the server's time zone. flock stops a slow run from overlapping the next one.
# m h dom mon dow command 0 7 * * 1 flock -n /tmp/weekly-digest.lock /srv/support-digest/weekly-digest.sh - 5
Or schedule it in CI
Anthropic's GitHub Action runs a prompt on a cron schedule. GitHub runs scheduled workflows only from the default branch and, in public repositories, disables the schedule after 60 days without repository activity.
name: Weekly digest on: schedule: - cron: "0 7 * * 1" jobs: digest: runs-on: ubuntu-latest permissions: contents: read id-token: write steps: - uses: actions/checkout@v6 - uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} prompt: "Follow prompts/weekly-digest.md and print the digest" claude_args: | --max-turns 40 --allowedTools "Read,Grep,Glob" - 6
Read the result
With JSON output each run ends with one object that includes the result, the session id and total_cost_usd. In GitHub Actions the result appears in the workflow run log unless the prompt posts it somewhere.
sourcesClaude Code docs: headless modeClaude Code docs: authenticationClaude Code docs: GitHub Actions
What breaks when Claude Code runs on a schedule?
Four things, and none of them is the timer. The timer is the solved part. What a scheduled run lacks is everything a person at the keyboard was quietly providing: a login, a memory of last time, a decision at the risky step and a reason to look at the result.
Credentials come first because they fail silently. Anthropic's authentication docs say a stored claude.ai login has an end date and that renewing early matters most for sessions that run unattended. A token from claude setup-token lasts one year, is printed once and is tied to the subscription of the person who created it. When ANTHROPIC_API_KEY is also set, headless mode uses the key, so check which credential a run is really billed to.
| What breaks | Why | What you would build |
|---|---|---|
| Credentials | A personal login ends, a personal token belongs to one person, and two credentials in one environment hide which one is used | One credential per purpose in a secret store, with an owner and a renewal date |
| State | Each headless run starts fresh. A session can be resumed on the machine that stores it, and a fresh CI runner stores none | A place outside the run for what was done, what was decided and what comes next |
| Gates | With nobody attached, a call that needs approval is denied, so the work stops instead of waiting | A step that holds the work and waits for a named person |
| The record | Output goes to a log that expires, and the cost of each run sits in its own JSON | A run record that outlives the job: outcome, cost, duration and who approved what |
sourcesClaude Code docs: authenticationClaude Code docs: headless modeClaude Code docs: GitHub Actions
How does ConvOps run Claude Code on a schedule?
ConvOps puts the schedule on the task and keeps the state, the gates and the record outside the run. Each time the schedule fires, it creates a task and an isolated run works that task through its workflow, one pod per run. Attended and unattended are the same workflow, so the process your team already walks in Claude Code is the one the schedule starts.
ConvOps does not sell or host models. Unattended runs can use your Claude subscription or an Anthropic API key. Add either one as a provider connection. Your plan's own limits apply. Isolated runs on ConvOps Cloud are included on paid plans, fair use: heavy use moves to your own runners. The same ConvOps schedule can start OpenCode on a provider key.
- 1
Run the workflow attended first
Connect Claude Code and walk the workflow yourself a few times. A step that confuses you at the keyboard will confuse a run at night.
- 2
Add a provider connection
Choose a Claude subscription token or an Anthropic API key. Send it through a one-time link, paste it while signed in, or point ConvOps at Google Secret Manager. ConvOps checks a subscription with one real call per model before a run relies on it.
- 3
Create an executor
An executor says which agent starts and on which connection. A Claude Code executor links to exactly one connection: the subscription or the key.
- 4
Describe the agent environment
The environment names the repository, the git access and any secrets the work uses. The subscription token reaches the run as a secret, never as a value in a tool call, a prompt or a log.
- 5
Add the schedule
Pick a cadence or a repeat rule and a time zone: every few minutes, hourly, daily, weekdays, weekly or monthly. See the next five runs before you save a schedule.
- 6
Read what ran
ConvOps records the cost, duration, queue wait, tokens, turns and outcome of every run. A schedule that belongs to a program skips a fire while its previous run is still going. A scheduled run that cannot start is logged with the reason, not silently dropped.
Should a scheduled run use a Claude subscription or an API key?
Either works; the difference is who it belongs to and how it is billed. Anthropic's docs describe the long-lived token as a credential for CI pipelines and scripts that authenticates with a Claude subscription, and recommend an API key for a secret shared across repositories because the token is tied to one person. Your plan's own limits apply to subscription use, so read them before you size a schedule.
| Question | Subscription token | Anthropic API key |
|---|---|---|
| Where it comes from | claude setup-token, printed once | The Claude Console |
| Who it belongs to | The person who created it | Not tied to one person's subscription |
| How use is counted | Against the subscription | Per token, on the API account |
| Works in bare mode | No | Yes |
| In ConvOps | A provider connection | A provider connection |
sourcesClaude Code docs: authenticationClaude Code docs: GitHub Actions
When is plain cron enough?
Plain cron is enough when one person owns the job, the run only reads and reports, and a bad run costs a few minutes. A weekly digest that nobody acts on without reading it fits that description. So does a nightly link check.
Move to something with gates and a record when the run changes things other people depend on, when more than one person needs to know what it did, or when the answer to "what did it cost last month" matters. If your team already runs a cluster, running Claude Code unattended on Kubernetes covers the pod, the image and the network rules in detail.
Frequently asked questions
What does it mean to run Claude Code on a schedule?
It means a timer starts Claude Code in headless mode with a saved prompt, and the run finishes with nobody typing. In ConvOps, a schedule on the task creates the work on a cadence and an isolated run walks it through the workflow. The run stops at the gates your team placed and leaves a record of its outcome and cost.
Can Claude Code run on a schedule with my laptop closed?
Yes, if the run lives somewhere other than the laptop. ConvOps runs each scheduled task in an isolated pod on ConvOps Cloud or on your own runners, so no machine of yours has to stay awake. A CI schedule and Anthropic's cloud scheduled tasks also work without your machine, while cron and the /loop command need theirs switched on.
Can a scheduled Claude Code run use a Claude subscription?
Yes. ConvOps accepts a Claude subscription or an Anthropic API key as the provider connection for unattended runs. Anthropic's docs describe a long-lived token, created with claude setup-token, for scripts and CI where a browser login is unavailable. Your plan's own limits apply, and ConvOps checks the subscription with one real call per model before a run relies on it.
How do I stop a scheduled run from overlapping the previous one?
In ConvOps, a schedule that belongs to a program skips a fire while its previous run is still going, and a run that cannot start is logged with the reason. With plain cron, wrap the command in a lock such as flock. In a Kubernetes CronJob, set the concurrency policy to Forbid. In CI, use the concurrency controls your CI system provides.
Where does a scheduled Claude Code run wait for approval?
At a gate on the workflow step, not in the session. A ConvOps gate holds the step until an explicit approval is given, recorded with the account that gave it, so the work waits for hours or days. A plain headless run cannot wait: with nobody attached, a call that needs approval is denied and the run moves on or fails.
Who should run Claude Code on a schedule?
It suits teams with recurring work that follows the same steps each time: a weekly support digest, a month-end reconciliation, a pipeline report or a nightly bug sweep. ConvOps is for the teams among them that want one process and one record for the whole team, with checkpoints where a person, a metric or a report should decide.