Monday, June 22, 2026

Codex known logging bug

 See:

  • https://github.com/openai/codex/issues/28224
  • https://www.reddit.com/r/OpenAI/comments/1ucf4px/openai_codex_has_a_bug_that_could_kill_your_ssd/ 

 Fix:

It is perfectly safe to disable or delete the ~/.codex/logs_2.sqlite file. This file is used exclusively for local logging and diagnostic data. It does not contain any of your conversation history, user preferences, API keys, or project state.

Codex has a known logging bug that continuously writes massive amounts of data (up to hundreds of gigabytes per year) to this database. Because of this, it is actively recommended to manage or disable it. [1]

How to Safely Disable or Manage It
To stop the file from burning through your physical drive, you can use the following safe methods:
1. Completely delete the file (or directory)
You can safely remove the file or the entire ~/.codex directory if you want to clear up space. Codex will simply recreate the directories/files as needed (though the excessive logging will resume).
rm ~/.codex/logs_2.sqlite
 
2. Redirect logging to RAM (Recommended for Linux/macOS)
To prevent the continuous disk writes without breaking the logging functionality, you can create a symlink to redirect the file into your system's /tmp/ folder. Data in /tmp/ is stored in RAM and is wiped when you restart your computer. 
# Ensure the codex directory exists
mkdir -p ~/.codex

# Move the current file out of the way or delete it
rm ~/.codex/logs_2.sqlite

# Create a symlink to /tmp
ln -s /tmp/logs_2.sqlite ~/.codex/logs_2.sqlite


3. Clear the associated WAL and SHM files
If your disk is suddenly filling up, check for logs_2.sqlite-wal and logs_2.sqlite-shm files. These SQLite temporary and Write-Ahead Log (WAL) files can grow to tens of gigabytes. You can safely delete these whenever the Codex application or CLI is fully closed.

 

Alternative: The Ultimate "Zero RAM" Fix
If you want to completely stop the logging without using any RAM or disk space, you can link the file to dev/null (the system black hole). This discards the logs instantly.
Run these commands:
rm ~/.codex/logs_2.sqlite
ln -s /dev/null ~/.codex/logs_2.sqlite
 
However, the above does not work. Codex cannot start and refers to missing the database. So have to use the /tmp redirect.
 
To automate this and ensure that Codex never consumes too much of your Mac's RAM, we can create a tiny, lightweight background script using macOS's built-in launchd system.
This script will run completely hidden in the background and silently wipe the RAM log file every 2 hours without interrupting your work.

Step 1: Create the Automation Configuration
Open your Terminal app and copy-paste this single, large command block. Press Enter to run it:
bash
cat << 'EOF' > ~/Library/LaunchAgents/com.user.clear_codex_ram.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://apple.com">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.user.clear_codex_ram</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/sh</string>
        <string>-c</string>
        <string>/usr/bin/killall -STOP Codex 2>/dev/null; /bin/echo -n "" > /tmp/codex_logs_2.sqlite; /usr/bin/killall -CONT Codex 2>/dev/null</string>
    </array>
    <key>StartInterval</key>
    <integer>7200</integer>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
EOF
(Technical note: The 7200 value represents 7,200 seconds, which tells macOS to run this exactly every 2 hours. It safely pauses Codex for a millisecond, truncates the file to 0 bytes, and resumes Codex).
  
Step 2: Activate the Script
Now, tell macOS to register and start running this background task immediately by pasting this command into Terminal:
bash
launchctl load ~/Library/LaunchAgents/com.user.clear_codex_ram.plist 
 
How to remove it in the future
If Codex ever releases an official software update that permanently fixes this bug, you can completely uninstall this background task by running these two commands:
bash
launchctl unload ~/Library/LaunchAgents/com.user.clear_codex_ram.plist
rm ~/Library/LaunchAgents/com.user.clear_codex_ram.plist
Your Mac is now fully protected! The symlink keeps the heavy writes completely off your physical SSD, and this background script keeps the log file from hoarding your active system RAM.

No comments:

Blog Archive

Followers