Ways to keep Codex running
Some keep one chat going, so Codex keeps its context; others start fresh each time.
| Option | Computer can sleep | Same chat | Where it stops | Best for |
|---|---|---|---|---|
Goal mode (/goal) | No, for local work | Yes | When the goal is met, or it needs a decision | One task with a clear finish line |
| Codex Cloud task | Yes | Yes | When the task is done; you review and open a pull request | Handing off a task before bed |
| Scheduled task in a chat | No, for local files: computer on, app running | Yes | Runs on its schedule: minutes, daily or weekly | Checking in on the same work at intervals |
codex exec from cron | No | Yes, with codex exec resume | Your cron rhythm; you wire it up yourself | Scripts and CI |
| Crewmark heartbeat | No | Yes | Working hours you set, even past midnight | A standing job taken from a board, issue by issue |
How to run Codex overnight
Give it a goal it can check
In the desktop app, the CLI or the IDE extension,
/goalstarts Goal mode: the goal text is both the first prompt and the finish line. If you aren't sure what done looks like,/planasks you questions and turns the outcome into a goal with measurable criteria. Include a check, like a test suite passing.# Interactive: plan the outcome, then hand Codex a goal it checks itself /plan /goal all tests in test/auth pass and the lint step is clean # Headless, from a script or cron: let it edit files in the workspace codex exec --sandbox workspace-write "Work through TODO.md in order" # Next morning, or on the next cron run: continue the same session codex exec resume --last "Continue with the next unchecked item in TODO.md"Keep the computer awake, or send it to the cloud
For local work on a Mac, turn on “Prevent sleep while running” in the desktop app. A Codex Cloud task runs in its own workspace and keeps working while your computer is asleep; start one by choosing Work in > Cloud and an environment.
Set approvals so it doesn't stop at 2am
A goal keeps the same sandbox and approval policy, and pauses when it needs a decision. Let it edit the workspace with
--sandbox workspace-write, or use “Approve for me” so a reviewer handles routine requests.--full-autois no longer supported, anddanger-full-accessbelongs only in an isolated runner or container.Plan for usage limits
Codex shares your ChatGPT plan's allowance: a rolling 5-hour window plus weekly limits, and cloud tasks draw from the same pool. ChatGPT Pro currently has no 5-hour limit; weekly limits may apply. Credits or an API key let local work keep going. See Claude Code vs Codex for the numbers.
Check in from your phone
In the ChatGPT app you can follow a task, approve commands and review diffs, for cloud tasks and for a Mac or Windows PC you've connected under Settings > Connections. The connected computer has to stay awake and online. See Codex remote control.
What stops a long Codex task
- A decision only you can make. Goal mode pauses instead of widening its own access, so check approvals before you leave.
- Sleep or a lost connection on local work. OpenAI suggests pausing the goal before you expect to lose connectivity and resuming it later.
- The usage limit, until the window resets or you add credits.
- Two chats editing the same files. Give parallel chats their own git worktrees.
- Running out of work. Once the goal is met it stops, which is what you want; for a list of tasks, keep them in a file it works through.
Give Codex a night shift
A long task ends; a job doesn't. Crewmark turns a Codex conversation into an AI employee with working hours and a heartbeat, so it keeps taking the next issue from a board without you queuing it.
Set the working hours
Working hours can run past midnight, so a night shift such as 22:00 to 07:00 works, weekdays only or every day. Outside its hours the employee sleeps and doesn't touch your plan.
Pick the heartbeat
Every 15, 30, 60, 120 or 240 minutes during its shift, the crewmark CLI queues a message into the same Codex conversation with
codex queue --resumeand starts it, so the employee picks up its next issue. Your computer has to stay on.Read the board in the morning
Each issue has its comments and activity log, and anything that needs you arrives as a message the employee waits on. See how to make Codex proactive and what an AI employee is.
FAQ
Can Codex run overnight?
Yes. Give it a goal with /goal, keep the Mac awake with “Prevent sleep while running” (or use a Codex Cloud task, which keeps working while your computer sleeps), set approvals so it doesn't wait on you, and review the result in the morning.
How do I run Codex in the background?
Run codex exec without the interactive interface, from a script, cron or CI, and continue the same session later with codex exec resume --last. Or start a Codex Cloud task from the web or desktop app and close the window.
What is Goal mode in Codex?
Goal mode, started with /goal, keeps Codex working toward a goal you write; the goal text is both the first prompt and the completion criteria. You can pause, resume, edit or clear it from the progress row in the desktop app.
Does Codex keep working when my computer is asleep?
Cloud tasks do. Local work needs the computer awake, which the desktop app's “Prevent sleep while running” setting handles on a Mac; a connected computer you control from your phone also has to stay awake and online.
Will a long Codex run hit my usage limit?
It can. Codex uses your ChatGPT plan's 5-hour window and weekly limits, and cloud tasks draw from the same allowance. Spread work across windows with a schedule or a heartbeat rather than one long burst.
Is it safe to run Codex unattended?
Keep --sandbox workspace-write or “Approve for me” on your own machine, use danger-full-access only in an isolated runner or container, and work in a repository where changes go through review.
Checked against OpenAI's Codex docs (long-running work, Codex Cloud, non-interactive mode, mobile, scheduled tasks) on November 8, 2026.