Run Claude Code Overnight

Run Claude Code on a remote host for work that must continue after your laptop disconnects, or use a time-limited sandbox for jobs that can finish and export their results within one session. Test disconnect and restart separately before relying on unattended runs.

Separate reattachment from restart

On a Linux VPS you administer, use tmux when the operator needs to reattach to an interactive terminal. For a fleet that needs structured logs and a restart policy, run an Agent SDK worker under a service manager such as systemd. The SDK supervises a Claude CLI subprocess with a shell, working directory, and session files. Define where the worker records each job’s status and where a reviewer retrieves the result.

Start with a harmless fixture job. Disconnect the SSH client, reconnect, and check whether work progressed. Then stop the worker in a separate test and observe what the supervisor actually starts. If the worker returns but opens a fresh job or repeats a completed step, fix the job recovery logic before enabling automatic retries.

Time the final export separately from the last model action. An overnight run that completed computation but missed delivery is still an incomplete handoff.

Hosting the Agent SDK - Claude Code Docs

Budget time for exporting results

E2B lists a one-hour session limit on Hobby and a 24-hour limit on Pro. Consider a time-limited sandbox when you can rebuild the test environment and export the result before expiry. Compare the job’s worst-case runtime with the session limit and reserve time for uploading the diff, test logs, and final status. For Daytona, confirm the configured timeout and artifact retrieval behavior, then run the same expiry test before choosing it.

For an illustrative workload, assume a 35-minute test run, 10 minutes of setup, and 10 minutes to export. That leaves five minutes within E2B Hobby’s one-hour limit. Simulate a slow test. If the deadline arrives before the artifacts are retrievable, shorten the job, give it a longer session, or move it to a persistent host.

Reserve time for the slowest required transfer and rerun the worksheet for a slower workload. These are planning assumptions until measured on the intended host.

Pricing | E2B — The AI Agent Cloud

Recover the workspace and the conversation

The Claude Agent SDK’s SessionStore can mirror transcripts to external storage and resume a session from a replacement host with a matching working directory. Keep the source revision, uncommitted work you need to recover, and completed-step records separately. A transcript can describe a file edit while the replacement checkout still lacks the edited file. Give the operator a single place to find both the session identifier and the saved work.

In a rehearsal, stop a run after it saves a checkpoint. Restore the checkout and checkpoint on a replacement host, then resume the session and verify that it continues from the expected step. If the conversation loads but the diff is missing, inspect artifact storage and workspace restoration first. Send the recovered diff and test output to a reviewer before merging.

Persist sessions to external storage - Claude Code Docs

Sources