Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Created January 14, 2026 21:11
Show Gist options
  • Select an option

  • Save pythoninthegrass/8843933df812cb9982264a516c4e3575 to your computer and use it in GitHub Desktop.

Select an option

Save pythoninthegrass/8843933df812cb9982264a516c4e3575 to your computer and use it in GitHub Desktop.
Mole launchagent for nightly macOS cleanup
<?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.mole.nightly</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/mo</string>
<string>clean</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>StandardOutPath</key>
<string>/tmp/mole-clean.log</string>
<key>StandardErrorPath</key>
<string>/tmp/mole-clean.err</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin</string>
</dict>
</dict>
</plist>
@pythoninthegrass
Copy link
Author

pythoninthegrass commented Jan 14, 2026

brew install mole

tw93/Mole#259 (comment)

Load via launchctl load ~/Library/LaunchAgents/com.user.mole.nightly.plist.

Pretty neat that mo defaults to the least invasive cleanup when run outside of a tty!

A few notes:

  1. This is for the homebrew installed version (see: absolute path)
  2. Runs at 3am my time
  3. Potentially if something goes wrong, the /tmp/mole-clean.err could get cleared out before the root cause is discovered - Not really concerned as I can test manually via launchctl start com.user.mole.nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment