I've always been a crontab guy. Recently I have decided to make the switch to Apple's launchd processes, and I am unable to get my first plist to run.
The
plutil -lint
command tells me the plist is formatted correctly. Actually, it outputs "OK".I have run the bash script manually and confirmed that it properly operates when manually initiated.
I have loaded the file using launchctl load and received the response "already loaded" on repeated attempts to do the same.
The problem must be in my PLIST definition. Please help me spot the error.
I expect this to run with the following conditions:
- Only while the user
jaredclemence
is using the system - Once immediately on login
- Every 15 minutes thereafter
- Change Directory to
/Library/WebServer/Documents/medface/
before running the script.
The plist file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.pediatricheartcenter.medface.crons</string>
<key>User</key>
<string>jaredclemence</string>
<key>ProgramArguments</key>
<array>
<string>/User/jaredclemence/runMedfaceSchedTasks.batch</string>
</array>
<key>WorkingDirectory</key>
<string>/Library/WebServer/Documents/medface</string>
<key>StartInterval</key>
<integer>900</integer>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Notes:
- I have stored the file in
~/Library/LaunchAgents/org.pediatricheartcenter.medface.crons.plist
- A previous version of the file used
Program
instead ofProgramArguments
with a<string>
value instead of an array.
<key>StandardOutPath</key>
and<key>StandardErrorPath</key>
- I'd suggest~/Library/Logs/org.pediatricheartcenter.medface.crons.stdout
(and...stderr
) as that's the usual logging location for launch agents, but use whatever works for you. Addecho
orprintf
s to the start and end ofrunMedfaceSchedTasks.batch
, and see what the logs say after youlaunchctl load
yourplist
.