Answer: Run Codex non-interactively by passing a task prompt as a single argument to `codex exec`, for example `codex exec "summarize the repository structure and list the top 5 risky areas"`. While it runs, Codex streams progress to `stderr` and prints only the final agent message to `stdout`, so you can redirect or pipe the result. Status: Confirmed Entry: tool/codex/agents-and-automation/run-codex-exec-non-interactive Revision: 2 Digest: sha256:c10ba82c4cd10b10 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:52:04Z Last changed: 2026-11-17T14:05:14Z (piping example: — → codex exec "generate release notes for the last 10 commits" | tee release-notes.md) Last verified: 2026-11-20T13:40:31Z Next check: 2026-11-21T13:40:31Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of basic command | codex exec "summarize the repository structure and list the top 5 risky areas" | [1] | 2026-11-20 progress output | stderr | [1] | 2026-11-20 final output | stdout | [1] | 2026-11-20 ephemeral flag | --ephemeral | [1] | 2026-11-20 piping example | codex exec "generate release notes for the last 10 commits" | tee release-notes.md | [1] | 2026-11-20 Sources: [1] OpenAI. "Non-interactive mode". https://learn.chatgpt.com/docs/non-interactive-mode.md Role: primary. Accessed: 2026-11-20T13:40:31Z Quote: "codex exec "summarize the repository structure and list the top 5 risky areas"" (Supports: basic command) Quote: "Codex streams progress to `stderr` and prints only the final agent message to `stdout`" (Supports: progress output, final output) Quote: "Use `--ephemeral` when you don't want to persist session rollout files to disk" (Supports: ephemeral flag) Quote: "codex exec "generate release notes for the last 10 commits" | tee release-notes.md" (Supports: piping example) Snapshot SHA-256: b1ad0560012e1cb7487e129659d672867cb172ec07f7a643654b4cf4df2c32f6 (captured 2026-11-17T14:05:14Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-17T14:05:14Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:40:31Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:40:31Z Last attempt: 2026-11-20T13:40:31Z Notes and limitations: Extracted automatically from a single official source (section "Basic usage"). Related: https://latestn.com/tool/codex/agents-and-automation/run-remediation-noninteractive How do I run Codex security remediation without interaction? https://latestn.com/tool/codex/agents-and-automation/trigger-subagent-workflows How do I enable or trigger subagent workflows in Codex and ChatGPT? https://latestn.com/tool/codex/commands-and-shortcuts/accept-composer-prediction How do I accept a composer prediction in the Codex desktop app? https://latestn.com/tool/codex/agents-and-automation/products-with-agentic-capabilities Which OpenAI products have agentic capabilities, like Codex and ChatGPT? https://latestn.com/tool/codex/agents-and-automation/resume-non-interactive-session How do I resume a non-interactive Codex exec session? https://latestn.com/tool/codex/agents-and-automation/resume-thread-without-history How do I resume a Codex SDK thread without loading its history? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-17T14:05:14Z | changed | piping example: — → codex exec "generate release notes for the last 10 commits" | tee release-notes.md | [1] 2026-11-17T14:05:14Z | changed | final output: — → stdout | [1] 2026-11-17T14:05:14Z | changed | progress output: — → stderr | [1] 2026-11-17T14:05:14Z | changed | piped stdin behavior: Codex treats the prompt as the instruction and the piped content as additional context → — | [1] 2026-11-17T14:05:14Z | changed | final message stream: stdout → — | [1] 2026-11-17T14:05:14Z | changed | progress output stream: stderr → — | [1] 2026-11-17T14:05:14Z | changed | basic command: codex exec → codex exec "summarize the repository structure and list the top 5 risky areas" | [1] 2026-11-13T03:52:04Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/codex/agents-and-automation/run-codex-exec-non-interactive/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/codex/agents-and-automation/run-codex-exec-non-interactive POST: https://latestn.com/dispute/tool/codex/agents-and-automation/run-codex-exec-non-interactive with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/codex/agents-and-automation/run-codex-exec-non-interactive?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I run Codex non-interactively in scripts or CI with codex exec? Revision 2, last verified 2026-11-20T13:40:31Z. https://latestn.com/tool/codex/agents-and-automation/run-codex-exec-non-interactive (accessed 2026-11-21T09:57:19Z). @misc{LatestN_tool_codex_agents_and_automation_run_codex_exec_non_interactive_r2, title = {How do I run Codex non-interactively in scripts or CI with codex exec?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/codex/agents-and-automation/run-codex-exec-non-interactive}}, note = {Revision 2; digest sha256:c10ba82c4cd10b10; last verified 2026-11-20T13:40:31Z; accessed 2026-11-21T09:57:19Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/codex/agents-and-automation/run-codex-exec-non-interactive