Skip to content

Instantly share code, notes, and snippets.

@adriangb
Last active March 14, 2025 15:36
Show Gist options
  • Save adriangb/2de71696aceed9338973377a5dab7e9d to your computer and use it in GitHub Desktop.
Save adriangb/2de71696aceed9338973377a5dab7e9d to your computer and use it in GitHub Desktop.
cargo install cargo-sweep
# Create a launchd job to run `cargo sweep --recursive --time 15 ~/GitHub`
# This will clean up all the cargo cache files older than 15 days
# Make it run once per day at midnight
# https://www.launchd.info/
# First, create a plist file for the launchd job
cat > ~/Library/LaunchAgents/com.user.cargosweep.plist << 'EOF'
<?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.cargosweep</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/cargo</string>
<string>sweep</string>
<string>--recursive</string>
<string>--time</string>
<string>15</string>
<string>~/GitHub</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>0</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>StandardErrorPath</key>
<string>/tmp/com.user.cargosweep.err</string>
<key>StandardOutPath</key>
<string>/tmp/com.user.cargosweep.out</string>
</dict>
</plist>
EOF
# Load the launchd job
launchctl load ~/Library/LaunchAgents/com.user.cargosweep.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment