I seeking help for to setup a periodical job on my imac with macOS Big Sur v11.4. What I want to do, is to delete all contents of a given folder every 60 seconds with a bash or zsh script. It doesn't matter which one. Default for terminal is set to zsh. Therefore I tried it with zsh.
My current approach is to have two files. A zsh script which deletes the folder contents and for 'launchd' I have a plist which periodically should calls the script.
If I call the zsh script in terminal it works fine and deletes the folder contents. But when it is called by launchd it returns with "no matches found" and I don't know where the problem is.
Therefore it would be very kind, if someone can help me with this.
/Library/LaunchDaemons/com.deleteGCODE.plist:
<?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.deleteGCODE.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/deleteGCODE.sh</string>
</array>
<key>StartInterval</key>
<integer>60</integer>
<key>StandardErrorPath</key>
<string>/tmp/mycommand.err</string>
<key>StandardOutPath</key>
<string>/tmp/mycommand.out</string>
</dict>
</plist>
/usr/local/bin/deleteGCODE.sh:
#!/bin/zsh
dir="/Users/simon/Documents/Simplify3D/GCODE/"
rm -rf "$dir"*
the output of /tmp/mycommand.out:
/usr/local/bin/deleteGCODE.sh:3: no matches found: /Users/simon/Documents/Simplify3D/GCODE/*
p.s. I am very sorry that I have postet my previous message in the wrong section. Hopefully this time it is correct.