Last active
August 29, 2015 13:56
-
-
Save pkutzner/8983538 to your computer and use it in GitHub Desktop.
LaunchAgent that runs periodically to clean out files from specified directory that are older than 7 days. Replace PATH_TO_CLEAR with the directory you want files deleted from. Change LOG_PATH and ERROR_LOG_PATH to appropriate files for logging. Remove if undesired.
This file contains hidden or 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
<?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>local.cleardir</string> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>EnableGlobbing</key> | |
<true/> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/bin/find</string> | |
<string>PATH_TO_CLEAR</string> | |
<string>-mindepth</string> | |
<string>1</string> | |
<string>-mtime</string> | |
<string>+7</string> | |
<string>-exec</string> | |
<string>rm</string> | |
<string>-rf</string> | |
<string>{}</string> | |
<string>\;</string> | |
</array> | |
<key>StartCalendarInterval</key> | |
<array> | |
<dict> | |
<key>Minute</key> | |
<integer>15</integer> | |
</dict> | |
</array> | |
<key>Debug</key> | |
<false/> | |
<key>AbandonProcessGroup</key> | |
<true/> | |
<key>StandardOutPath</key> | |
<string>LOG_PATH</string> | |
<key>StandardErrorPath</key> | |
<string>ERROR_LOG_PATH</string> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment