Developer builds nightly script to stop Claude Code logs from bloating disk storage
A developer shared a custom shell script designed to prevent log files generated by Claude Code from consuming excessive disk space. The logs, stored in ~/.claude/logs/, were found to grow rapidly, with some files exceeding 5MB within a single week and the entire directory reaching 20MB. The script runs nightly at 3:45 AM via macOS launchd, targeting any log file over 5MB and trimming it to the last 2,000 lines. Rather than using standard log rotation, which creates new files and breaks path-based monitoring tools, the script overwrites the original file in place to preserve the inode and file path. Files older than 30 days are also automatically deleted to further manage storage.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in