I have the following launchd saved as an agent in:
<?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.desktop.cleanup</string> <key>ProgramArguments</key> <array> <string>zsh</string> <string>-c</string> <string>/usr/local/bin/trash ~/Desktop/Screen*</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>3600</integer> <key>StandardErrorPath</key> <string>/tmp/local.desktop.cleanup.err</string> <key>StandardOutPath</key> <string>/tmp/local.desktop.cleanup.out</string> <key>KeepAlive</key> <dict> <key>NetworkState</key> <true/> </dict> </dict> </plist>
It runs a very simple program that moves, instead of removes, the selected files to the bin. I’ve only been testing the launchd’s success with RunAtLoad and I cannot get it to work. I get the following error in my log file after each time I log in:
zsh:1: no matches found: /Users/my_name/Desktop/Screen*
My Desktop is actually one of those icloud folders that I suppose MacOS just has symlinked. My theory is that maybe these files do not exist locally at the point the program is run. If this is the case, or not, I would appreciate any ideas or solutions to make this specific use case work.
N.B. You’ll noticed I left KeepAlive NetworkState in to show I attempted to delay the run until the network was “alive”, however, this wouldn’t account for downloading any files.