I am trying to get a script to run from launchd at regular intervals. The service loads but does not run the script.
The script itself is a very simple test script as follows:
echo "Hello World!" >> /Users/rhiannon/Library/Application\ Support/Script\ Testing/test.txt
The script is saved as
/Users/rhiannon/Library/Application\ Support/Script\ Testing/test-launchd.sh (with permissions
rwxr-xr-x) and happily runs from the command line.
I have a plist file as follows:
<?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>uk.co.myco.timedshelltests</string> <key>Program</key> <string>/Users/rhiannon/Library/Application\ Support/Script\ Testing/test-launchd.sh</string> <key>StartInterval</key> <integer>60</integer> </dict> </plist>
The plist file is saved as
/Users/rhiannon/Library/LaunchAgents/uk.co.myco.timedshelltests.plist with permissions
I load the service using
launchctl load uk.co.myco.timedshelltests.plist
With logging set with
sudo launchctl log level debug, I see the following error in the system log:
com.apple.xpc.launchd (uk.co.myco.timedshelltests): Could not find and/or execute program specified by service: 2: No such file or directory: /Users/rhiannon/Library/Application\ Support/Script\ Testing/test-launchd.sh com.apple.xpc.launchd (uk.co.myco.timedshelltests): Service setup event to handle failure and will not launch until it fires. com.apple.xpc.launchd (uk.co.myco.timedshelltests): Service exited with abnormal code: 78
I'm pretty certain the permissions are correct, and I know the path is correct. What else could be wrong?