launchd - is my job already loaded?
I have a need for a periodic (in this case, twice per day) per user task. I have written a job file and all works great from the command line using launchctl, but I want to set up this task programatically. Is there an API for launchd/launchctl, or should I just fork+exec launchctl to setup my job? Is there a prettier way to determine if my job is already loaded than to exec `launchctl list` and grep the output? Jim
On Feb 27, 2009, at 11:29 AM, Jim Correia wrote:
Is there an API for launchd/launchctl, or should I just fork+exec launchctl to setup my job?
Answering my own question, here is an earlier post by Quinn: http://lists.macosforge.org/pipermail/launchd-dev/2009-February/000483.html Jim
At 11:29 -0500 27/2/09, Jim Correia wrote:
Is there a prettier way to determine if my job is already loaded than to exec `launchctl list` and grep the output?
You don't need to grep. You can add your job label to the command and then test the exit status: $ launchctl list com.apple.coreservices.uiagent > /dev/null 2>&1 ; echo $? 0 $ launchctl list com.apple.dts.not.really.a.job > /dev/null 2>&1 ; echo $? 1 S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
participants (2)
-
Jim Correia
-
Quinn