Check your permissions. The file script.plist should look like this
-rw-r--r-- 1 wheel 410 16 ...
From man launchctl
Note that per-user configuration files (LaunchAgents) must be owned by the user loading them. All system-wide daemons (LaunchDaemons) must be owned by root. Configuration files must not be group- or world-writable.
You backup task is (very) user-specific and no system service, so the proper location for the launch agent is ~/Library/LaunchAgents/. If you put the plist in /Library/LaunchAgents it will run on behalf of every user logged in at ~ 5.11pm - which will fail for most users because they probably can't access some or most of your user folders/files.
Use a proper shebang in the script #!/bin/bash..
and make the script executable: chmod +x /Users/Study/Library/Scripts/spidbackup.sh
.
Completely remove the plist from the launchctl db with sudo launchctl remove com.spidbackup
and launchctl remove com.spidbackup
. Move the plist to /Users/Study/Library/LaunchAgents/, chown/chmod it to your user and remove the key WorkingDirectory and the associated string.
Finally reload the agent with:
launchctl load /Users/Study/Library/LaunchAgents/com.spidbackup.plist
The proper permissions/ownerships for the files are finally:
ls -l /Users/Study/Library/Scripts/spidbackup.sh
-rwxr-xr-x 1 study staff ... spidbackup.sh
or
-rwx------ 1 study staff ... spidbackup.sh
and
ls -l /Users/Study/Library/LaunchAgents/com.spidbackup.plist
-rw-r--r-- 1 study staff ... com.spidbackup.plist
assuming Study is your user name.
Please also check capitalization (e.g. study vs. Study).
Best Answer
TL;DR
The default value is
/
, as inExplanation
The
WorkingDirectory
in a launchd.plist
is an optional key used to specify a directory to chdir(2) to before running the job. If this key is not present, then the root/
directory is used.I verified this by running a shell script as both a Launch Agent and a Launch Daemon that, when run, appended a directory listing to a text file. In all cases, without the
WorkingDirectory
key, the output was the root/
directory of the startup disk.Depending on whether or not it was run as root or the current user the output as root also contained the hidden directories even though that was not explicitly set to output by the script.
As a side note, the
PATH
passed to the shell script when run as both a Launch Agent and Launch Daemon was:Note that this was tested under OS X 10.8.5.