Last active
November 2, 2023 13:38
-
-
Save joemaller/c4c0a6000ac53c8b1a70ff66c547380a to your computer and use it in GitHub Desktop.
Example cron task for auto-removing old downloads on macOS Big Sur and Catalina
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cron on modern macOS systems (10.14+) requires Full Disk Access permissions | |
# in System Preferences->Privacy & Security. To enable this, drag the cron | |
# binary from /usr/sbin/cron into the Full Disk Access list. | |
# More here: https://apple.stackexchange.com/a/372810/42898 | |
# https://gist.github.com/joemaller/c4c0a6000ac53c8b1a70ff66c547380a | |
# Removes downloads older than 14 days. Runs every 6 hours | |
45 */6 * * * echo "$(date)\nRemoving downloads older than 14 days (cron)" >> /tmp/cron.log | |
45 */6 * * * find ~/Downloads -maxdepth 1 -mtime +14 -exec du -sh {} \+ | sort -rh >> /tmp/cron.log | |
46 */6 * * * find ~/Downloads -maxdepth 1 -mtime +14 -exec rm -rf {} \; >> /tmp/cron.log 2>&1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment