Claude Code Background Task Dies at 30 Minutes?

Claude Code Background Task Dies at 30 Minutes?

Aident AI

A cyan current passes through a coral threshold and continues as a calm green arc over deep indigo paper layers.

Claude Code Background Task Dies at 30 Minutes?

If a Claude Code background Bash task stops at almost exactly 30 minutes and reports exit code 144, first prove that it received SIGTERM. Do not assume the command timed out, restart it repeatedly, or expect nohup to block a termination signal. Preserve the timestamps and task output, rule out Claude Code's documented cleanup conditions, then run work that must outlive the session under a supervisor started outside Claude Code.

This guide addresses a narrow failure reported on macOS in Claude Code issue 84981. The issue remains open, so the exact internal cause is not confirmed. Use the runaway-child guide when a child process survives and consumes memory instead. Use the Remote Control disconnect guide when the session disconnects but the task itself has not shown a signal or exit status.

Confirm the 30-Minute Pattern Before Changing the Job

The August 8 report describes tracked Bash tasks launched with run_in_background: true on Claude Code 2.1.221 for macOS. The reporter captured two SIGTERM events exactly 1,800 seconds apart and saw exit code 144 when the harness classified a terminated task as failed. They also reported that some tasks crossed a timer boundary normally, so even their evidence does not establish that every background command has a universal 30-minute limit.

Claude Code's official interactive-mode documentation says background Bash commands run asynchronously, write output to a file, and receive a task ID. It documents automatic cleanup when Claude Code exits and termination when output exceeds 5 GB. It does not document a 30-minute lifetime.

Treat these observations as separate facts:

Observation

What it supports

What it does not prove

Task stopped near 30 minutes

A timer-related failure is plausible

Claude Code sent the signal

Exit code 144

A shell may be reporting 128 + 16, consistent with SIGTERM

Which process sent the signal

Session stayed open

Normal exit cleanup is less likely

Compaction, an extension, or another host process played no role

Output stayed small

The documented 5 GB cutoff is less likely

Every output file and child stream stayed under the limit

Before retrying, capture the version, platform, start time, stop time, task ID, and last output line. Keep secrets, prompts, repository paths, remote hostnames, and process arguments out of any public report.

claude --version
date -u +%Y-%m-%dT%H:%M:%SZ
uname -a

If you can reproduce safely, use a harmless local probe rather than the production job. Save this as /tmp/claude-bg-probe.sh, then ask Claude Code to run it in the background:

#!/bin/sh
trap 'printf "%s SIGTERM\n" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" >&2; exit 144' TERM
printf "%s started\n" "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
while :; do
  sleep 60
  printf "%s alive\n" "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
done

The useful result is not merely "stopped." You want the last heartbeat, the trapped signal, the task status, and the elapsed time. Stop after one controlled reproduction. Do not leave multiple probes running.

Rule Out the Documented Cleanup Paths

Check four boundaries before attributing the signal to an undocumented timer.

  1. Session exit: Claude Code documents that it cleans up background tasks when the session exits. Confirm that the original Claude process stayed alive across the task stop.

  2. Output size: Verify the task did not produce gigabytes of logs. Redirect noisy application output to a bounded log with rotation rather than flooding the background-task output file.

  3. Explicit stop: Check that neither you nor the agent used the task-stop control. Preserve the transcript around the stop time.

  4. Host supervision: Check launch agents, CI timeouts, remote-shell idle policies, sleep behavior, and application wrappers. A task polling over SSH can be terminated locally even when the remote process is healthy.

Also compare one foreground run and one background run with the same harmless probe. If only the tracked background run stops, that narrows the boundary. If both stop, investigate the shell, host, remote connection, or command itself before blaming Claude Code.

Do not delete Claude settings, authentication state, task files, or the repository. Those actions destroy evidence and do not explain a signal delivered to a running process.

Update First, but Keep the Reproduction

Record the affected Claude Code version, then allow the supported native installation to update normally. Claude Code's installation documentation says native installs update automatically in the background. After updating, restart Claude Code once and repeat the harmless probe.

A passing probe on a newer version is useful evidence, but it is not proof of a fix unless the upstream issue or release notes identify one. A failing probe should include both version results in the report.

Avoid changing several variables at once. If you update Claude Code, disable an extension, change Remote Control, and rewrite the job simultaneously, you will not know which boundary mattered.

Move Jobs That Must Outlive Claude Code Outside the Session

Claude Code background Bash is designed for work that continues while the current session handles other prompts. It is still session-managed: official documentation says those tasks are cleaned up when Claude Code exits. A deployment, overnight data job, remote poller, or other process that must survive session cleanup belongs under an operating-system supervisor, CI system, or terminal multiplexer started outside Claude Code.

For an interactive job on macOS or Linux, open a normal terminal that is not a Claude Code Bash task and start a named tmux session:

tmux new-session -d -s long-job \
  'cd /absolute/path/to/project && ./scripts/long-job.sh > long-job.log 2>&1'

Inspect it from that same normal terminal:

tmux list-sessions
tmux attach-session -t long-job

Use launchd, systemd, or your CI provider when the job needs restart policy, resource limits, credentials, or durable scheduling. Store credentials in that supervisor's secret mechanism, not in the command line or log file.

Do not rely on nohup alone for this symptom. nohup addresses hangups, while the reported failure is SIGTERM. Likewise, adding & or disown inside the same tracked Bash invocation does not establish that Claude Code has stopped tracking the process tree. The safer boundary is a supervisor launched outside the affected session.

Verify the External Job and Keep Claude Code Read-Only

After moving the job, verify that it crosses the suspected boundary and produces the intended output:

date -u +%Y-%m-%dT%H:%M:%SZ
tail -n 20 long-job.log

Ask Claude Code to inspect the log and process state without restarting, killing, or modifying the job. The recovery is confirmed when:

  • the external job runs beyond the prior failure time;

  • its log shows expected progress and no repeated restarts;

  • ending the Claude Code session does not stop it;

  • the task completes or reaches its own explicit timeout; and

  • no orphaned child remains after completion.

Once upstream behavior changes, move short development commands back to Claude Code background tasks if that is more convenient. Keep genuinely durable operations under durable supervision.

Monitor the Upstream Issue With Aident Loadout

You can check the public issue without pasting GitHub credentials into a prompt. Start with:

Follow https://aident.ai/SETUP.md

Then ask your agent:

Check Aident Loadout authentication and Vault status. Discover the current read-only GitHub issue Action, inspect its schema, and preflight a lookup for anthropics/claude-code issue 84981. If it is valid and free, execute it and return only state, updated time, labels, comment count, title, and canonical URL. Do not comment, react, edit, close, or create anything.

The Aident Loadout first-task guide explains the account, Vault, discovery, schema, preflight, and execution sequence. The measurable result is a current issue-state record with zero GitHub writes.

Set up Aident Loadout and monitor the Claude Code issue.

Sources

Refresh this guide when issue 84981 changes state, Anthropic documents a background-task lifetime, or a current Claude Code release changes session cleanup or task supervision.

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

The one tool

for every tool

your agent needs.

Give any AI agent real capabilities in seconds. Connect 1,000+ tools once, skip the setup headache, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.