Overview
Use system cron to start read-only codex exec runs on a server that check pending updates, known vulnerabilities and security logs, with each run writing a handoff note that the next run reads.
Problem or Objective
- Which models and agents find security bugs in code?
- Which agents investigate monitoring alerts for on-call staff?
More in Security Research
AI Agents and Models
Tools and Integrations
- Tools
- Codex CLI · cron
- Prerequisites
- A Linux server with cron, the Codex CLI installed and authenticated (saved CLI login or CODEX_API_KEY), and permission to read the logs and package lists you want checked.
How It Works
On the server, create a working folder with a HANDOFF.md file and a short task file per check: pending package updates, dependency vulnerabilities in your deployed projects, and the last day of authentication and web server logs. Write a small shell script that runs codex exec for one check in the default read-only sandbox, passes the current HANDOFF.md as context, and writes the final message to a dated report with --output-last-message. The script then copies the report's open items into HANDOFF.md so the next run continues from them. Add one cron entry per check at quiet hours. Set the API key only for the Codex call. Read the reports each morning; Codex suggests fixes but changes nothing, and you apply updates or configuration changes yourself after checking them. Treat a suspicious log line as a lead to investigate, not as a confirmed intrusion.
Implementation Workflow
Steps assembled from the agents, tools and prompt of this entry. Adapt them to your own setup.
- Choose the agentSet up Codex CLI.
- Connect the toolsConnect the tools this workflow relies on: Codex CLI, cron.
- Check the prerequisitesA Linux server with cron, the Codex CLI installed and authenticated (saved CLI login or CODEX_API_KEY), and permission to read the logs and package lists you want checked.
- Gather your detailsCollect what the prompt asks for: Server name, The check for this run, Logs to read.
- Run the starter promptPaste the starter prompt below into Codex CLI and adapt it to your case.
- Check against the documentationCompare what you get with the documentation at developers.openai.com before you rely on it.
Practical Starter Prompt: Run one scheduled security check
Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].
You are running unattended on [Server name] in a read-only sandbox. Read HANDOFF.md for open items from earlier runs. Then do this check only: [The check for this run]. Look at [Logs to read] where relevant. Report findings with the evidence for each, rate them low, medium or high, and suggest a fix, but change nothing. End with an Open items list for the next run. Mark anything you could not verify as unverified. A person reviews the report and applies any change by hand.Each run only reads and reports. A person reviews the reports and applies any update or configuration change by hand after checking it.
Expected Results and Benefits
This is a suggested workflow, not a reported result. The points below are what the cited documentation says the tools can do.
This is a suggested workflow, not a reported outcome. OpenAI's non-interactive mode page says codex exec suits pipelines and scheduled jobs, runs in a read-only sandbox by default, can write its final message to a file, and can resume a previous run. The page does not cover reading system logs or package managers specifically; those are ordinary shell commands the run must be allowed to execute, so test each check by hand first.
Limitations and Considerations
Keep the default read-only sandbox for these checks, and use danger-full-access only in a controlled environment such as an isolated runner or container, as OpenAI advises. Set CODEX_API_KEY only for the Codex invocation and make sure no untrusted code runs in the same process environment. Logs can contain personal data and secrets, so check what you send to the model and how long reports are kept. API usage costs money per run; watch it for the first weeks. Results depend on your setup and were not independently reproduced by Top 200 Repos.
GitHub Repositories
AI Agent Repository
Source code of the agent that does the work.
Related Videos
About openai/codex
Meet the New Codex CLI (opens in a new tab)
Published by the project’s official channel.
Watch on YouTube (opens in a new tab)Independent creators. Listing a video implies no endorsement, sponsorship or partnership.
Sources
- Non-interactive mode | ChatGPT Learn (opens in a new tab)
Project documentation · developers.openai.com · Undated · Source checked 27 Nov 2026, 10:47 UTC
What this source supports
- Use codex exec when you want Codex to run as part of a pipeline (CI, pre-merge checks, scheduled jobs) with explicit, pre-set sandbox and approval settings.
- By default, codex exec runs in a read-only sandbox; use danger-full-access only in a controlled environment, for example an isolated CI runner or container.
- -o or --output-last-message writes the final message to a file, and codex exec resume continues a previous run.
- For automation environments, set CODEX_API_KEY only for the Codex invocation that needs it, and make sure no untrusted code runs in the same process environment.
