Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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

Reply
Question marked as Best reply

Posted on Mar 3, 2016 12:01 AM

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).

2 replies
Question marked as Best reply

Mar 3, 2016 12:01 AM in response to Buadhai

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).

Mar 3, 2016 12:08 AM in response to Camelot

Thank you.


I don't see anything in the system.log that tells me what's going on. The shell script that I run keeps a log, so I can see the exact time that it happened because log entries stop. (And, since the script captures and time stamps a photo, I can also see when the last photo was processed.")


Your hint that the script might be taking more than four minutes to run helped a lot. Looking at the log that the script keeps, I can see that during the last successful run, the script seems to have started, but never finished. I think I know what caused this and have removed the offending lines.


I have also removed the RunAtLoad key from the plist.


So far, so good.


Thanks for your help. I learned something. Well, more than one thing.

Why Does My Launchd Job Suddenly Stop

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.