Q: Why Does My Launchd Job Suddenly Stop
OSX 10.9.5
MacBook Air 11 Inch Late 2010
I have a launchd job running on this MacBook. The job runs a shell script every four minutes. That shell script captures a webcam image and uploads it to my website.
Most of the time this works just fine. But, every once in a while the launchd job simply stops. if I unload and reload the plist file, the job starts running again. Other jobs continue to run without problems.
What can stop a job from running?
The job was created with Lingon X.
<?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>Disabled</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/sb in</string>
</dict>
<key>Label</key>
<string>com.mgnewman.webcam</string>
<key>ProgramArguments</key>
<array>
<string>/Users/mnewman/bin/chaamcam.sh</string>
</array>
<key>QueueDirectories</key>
<array/>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>240</integer>
<key>WatchPaths</key>
<array/>
</dict>
</plist>
Posted on Feb 29, 2016 6:12 PM
The first question I have is what do the logs have to say about it?
Any error condition should be logged in /var/log/system.log so that's the place to start.
Beyond that, processes may get throttled if they spawn too frequently, and a job may not be kicked off if its previous incarnation is still running - is it possible that it's taking more than 4 minutes for the script to run, and that's blocking the next invocation?
In either case, you should remove the RunAtLoad key from your .plist, since it doesn't apply here (man launchd.plist has more detail on this key).
Posted on Mar 3, 2016 12:01 AM