[launchd-dev] launchd - is my job already loaded?

Quinn eskimo1 at apple.com
Thu Mar 5 03:43:41 PST 2009


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


More information about the launchd-dev mailing list