# Run Claude Code on a schedule in the cloud

> Run Claude Code every night or every hour on a cloud machine that is on when the schedule fires: cron on a box that stays awake, or a scheduler that wakes a sleeping box through the API, with what each costs.

URL: https://prized.dev/docs/run-claude-code-on-a-schedule
Updated: 2026-10-25

A cron job on your laptop runs only while the laptop is awake, so a schedule needs a machine that stays on. On a box, Claude Code runs headless (`claude -p`) with your sign-in, either from cron on the box or from any scheduler that calls the API, which wakes the box first.

## 1. Put your project on a box [#1-put-your-project-on-a-box]

Sign up at [prized.dev](https://prized.dev/sign-in): the tour starts a box on $30 of free credit with no card, then shows one command that installs the CLI and signs this machine in ([Quickstart](https://prized.dev/docs/quickstart)). Or install it yourself, then sign in:

```bash
curl -fsSL https://prized.dev/install.sh | sh
```

```bash
prized login
```

Then, in your project folder:

```bash
prized setup --agent claude
```

It syncs this folder with `~/code/myproject` on the box and copies your Claude Code sign-in there ([Credentials](https://prized.dev/docs/credentials)). `BOX` below is your box's name, from `prized box ls`.

## 2. Schedule it with cron on the box [#2-schedule-it-with-cron-on-the-box]

A sleeping box runs no cron, so keep this one awake:

```bash
prized box auto-pause BOX off
```

Then `prized ssh` and, on the box, save the job as a script. `#!/bin/bash -l` gives it your login shell's `PATH`, where `claude` is; cron's own `PATH` does not have it.

```bash title="~/nightly.sh"
#!/bin/bash -l
cd ~/code/myproject
claude -p --dangerously-skip-permissions "run the test suite and fix what fails" >> ~/nightly.log 2>&1
```

```bash title="you@box"
chmod +x ~/nightly.sh
(crontab -l 2>/dev/null; echo "0 7 * * * $HOME/nightly.sh") | crontab -
```

Cron reads the time in UTC, the box's time zone. `claude --dangerously-skip-permissions` runs any command your user on the box can, with your synced projects and sign-ins in reach; to limit it, leave the flag out and list what it may run, such as `claude -p "…" --allowedTools "Bash(npm test)" Edit`. Its edits sync to your laptop with the folder ([Sync](https://prized.dev/docs/sync)).

## Or let the box sleep between runs [#or-let-the-box-sleep-between-runs]

Any scheduler that can run `curl` can start the run instead: `POST /prompts` wakes a sleeping box and runs Claude Code there headless ([Prompt an agent remotely](https://prized.dev/docs/remote-agents#the-edge-api)). Give the box an auto-pause window longer than a run, so it sleeps again once the run is done: a run counts as use for one window after it starts, then only while it keeps the CPU or network busy ([Auto-pause](https://prized.dev/docs/boxes#auto-pause)).

```bash
prized box auto-pause BOX 2h
```

Make a key at [API keys](https://prized.dev/dashboard/workspace/api-keys) with **Boxes: Write** and a year's lifetime (the default is 90 days), save it as a `PRIZED_API_KEY` repository secret, and this workflow starts a run every morning at 07:00 UTC (GitHub can start a scheduled workflow late):

```yaml title=".github/workflows/nightly-claude.yml"
on:
  schedule:
    - cron: "0 7 * * *"
jobs:
  claude:
    runs-on: ubuntu-latest
    steps:
      - env:
          PRIZED_API_KEY: ${{ secrets.PRIZED_API_KEY }}
        run: |
          AUTH="Authorization: Bearer $PRIZED_API_KEY"
          EDGE=$(curl -s -H @<(echo "$AUTH") https://api.prized.dev/api/v1/me | jq -r .edge.url)
          curl -s --fail-with-body -X POST "$EDGE/v1/box/BOX/prompts" -H @<(echo "$AUTH") -H "Content-Type: application/json" -d '{"provider":"claude","cwd":"code/myproject","auto":true,"prompt":"run the test suite and fix what fails"}'
```

`"auto": true` runs `claude --dangerously-skip-permissions` ([Approvals](https://prized.dev/docs/remote-agents#approvals)). Once the box is awake, `prized prompt ls` lists the runs with how each ended.

## Before you rely on it [#before-you-rely-on-it]

* **Quiet hours.** On a workspace with [quiet hours](https://prized.dev/docs/teams#quiet-hours), a box woken inside the window is paused again after 15 minutes; the owner marks the box **Exempt** on its page.
* **The sign-in.** The copied Claude Code sign-in refreshes on the box, and one side eventually asks you to `/login` again. For runs nobody watches, a long-lived token from `claude setup-token`, set on the box as `CLAUDE_CODE_OAUTH_TOKEN`, avoids that ([Prompt an agent remotely](https://prized.dev/docs/remote-agents#sign-in-first)).

## What it costs [#what-it-costs]

|  | Nano (2 vCPU, 2 GB) | Small (4 vCPU, 16 GB) |
| --- | --- | --- |
| Awake, per hour | $0.014 | $0.137 |
| Asleep, per hour (its disk) | $0.004 | $0.030 |
| Awake 2 hours a night and asleep the rest, 30 days | $3.46 | $28.02 |
| Awake around the clock, 30 days | $9.86 | $98.63 |

The model's usage is billed by your Claude plan or API key, not by Prized ([Billing](https://prized.dev/docs/billing)).
