<?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>me.lri.clear.desktop.and.documents</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>-e</string>
<string>say "lol"</string>
<!-- <string>tell application "Finder"
move items of desktop to trash
move items of (path to documents folder) to trash
end tell</string> -->
</array>
<key>StartInterval</key>
<integer>5</integer> <!-- every 5 seconds -->
<!-- <key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>23</integer>
<key>Minute</key>
<integer>0</integer>
</dict> -->
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
代理将在注销并重新登录后加载,或者在运行launchctl load ~/Library/LaunchAgents/me.lri.clear.desktop_and.documents.plist.
查看man launchctl和man launchd.plist了解更多信息。
另一种选择是将这样的内容添加到您的 crontab 中:
0 0 0 * * osascript -e 'tell app "Finder"' -e 'move items of desktop to trash' -e 'move items of (path to documents folder) to trash' -e 'end'
(您可以将其另存为~/.crontab,然后运行crontab ~/.crontab)