How to raise the 10-minute background wait in claude -p with an environment variable
After its final turn, claude -p keeps waiting for background subagents, workflows and Monitor watches that Claude started. After 10 minutes of idle waiting it stops what's left and drops the partial results. If a long scripted or CI run comes back empty, check this cap first.
From 2.1.328 (November 19), in a -p run with fork mode off (CLAUDE_CODE_FORK_SUBAGENT=0), a background subagent and the subagents it waits for all count against one 10-minute wait. If you chain subagents several levels deep, raise the cap.
- The value is in milliseconds; the default is
600000(10 minutes).
CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=1800000 claude -p "run all the tests and summarize the failures"
- Set it to 0 to wait with no cap.
CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=0 claude -p "run all the tests and summarize the failures"
The idle wait starts over each time Claude takes a turn to handle a background result. A background command the main conversation started (a dev server, a watch build) holds the run open until it exits, regardless of the cap. The variable has been available since 2.1.182.
Sources
Get notified when a new tip lands
Tip alerts only go out in the app. Install it and turn notifications on.