Skip to content

Instantly share code, notes, and snippets.

@ronaiza-cardoso
Created August 3, 2026 18:05
Show Gist options
  • Select an option

  • Save ronaiza-cardoso/87fb8c5a8369082273f8b4f1b8a32f40 to your computer and use it in GitHub Desktop.

Select an option

Save ronaiza-cardoso/87fb8c5a8369082273f8b4f1b8a32f40 to your computer and use it in GitHub Desktop.
macOS launchd agent to auto-prune stale Cursor log directories

cursor-logs-prune

A launchd agent that auto-prunes stale Cursor log directories on macOS.

Why

Cursor writes logs into ~/Library/Application Support/Cursor/logs/ — one date-stamped subdirectory per session — and never cleans them up. Left alone, the directory can accumulate tens or hundreds of GB and fill the disk.

The files hold no useful state; deleting them is safe (Cursor recreates the directory on next launch).

What it does

Runs daily at 3 AM and removes any top-level session directory older than 7 days:

find "$HOME/Library/Application Support/Cursor/logs" \
    -mindepth 1 -maxdepth 1 -type d -mtime +7 \
    -exec rm -rf {} +

Install

cp com.user.cursor-logs-prune.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.user.cursor-logs-prune.plist

Verify

launchctl list | grep cursor-logs-prune

Dry run:

find "$HOME/Library/Application Support/Cursor/logs" \
    -mindepth 1 -maxdepth 1 -type d -mtime +7

Run output: /tmp/cursor-logs-prune.log.

Disable

launchctl unload ~/Library/LaunchAgents/com.user.cursor-logs-prune.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.cursor-logs-prune</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>find "$HOME/Library/Application Support/Cursor/logs" -mindepth 1 -maxdepth 1 -type d -mtime +7 -exec rm -rf {} +</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>RunAtLoad</key>
<false/>
<key>StandardOutPath</key>
<string>/tmp/cursor-logs-prune.log</string>
<key>StandardErrorPath</key>
<string>/tmp/cursor-logs-prune.log</string>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment