I have a simple script that creates a new directory based on the date then copies a set of files to that directory. It runs fine from Terminal. When I set it up to run as a UserAgent it fails. The error log shows that has changed to paths from
/var/root/xxx. I've tried running it as
root from Terminal and it still works. I've ensured
root is not the owner of the script file. I've changed my original path of
~/xxx to the
/Users/Study/xxx but for some reason when run from launchd it changes the path. Any ideas?
!/bin/bash MO=$(date +%d%B%Y) mkdir /Users/Study/Dropbox/SPID_backups/$MO cp -r /Users/Study/WebDevelopment/SPID/*.* /Users/Study/Dropbox/SPID_backups/$MO
<?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.spidbackup</string> <key>Program</key> <string>/Users/Study/Library/Scripts/spidbackup.sh</string> <key>StandardErrorPath</key> <string>/tmp/com.spidbackup.err</string> <key>StandardOutPath</key> <string>/tmp/com.spidbackup.out</string> <key>StartCalendarInterval</key> <array> <dict> <key>Hour</key> <integer>17</integer> <key>Minute</key> <integer>11</integer> </dict> </array> <key>WorkingDirectory</key> <string>/Users/Study</string> </dict> </plist>