OSX: how to check return value of launchctl command

On OSX, using launchctl to start and stop a service seems great, however I don’t see it anyway to check the return value to make sure it really started. The return value is always returned as zero, even when the service did not start.

This plist file contains an error and, therefore, will not start "Rain" as expected

% launchctl start /Library/LaunchDaemons/org.drizzlebad.plist

% echo $?

0

Any suggestions other than checking for the presence of a pid file for this service?

+5
source share
2 answers

You must do something wrong, because it launchctlreturns 0 only on successful execution:

$ launchctl start foobar
launchctl start error: No such process
$ echo $?
1

, launchctl start ( , DNS-), plist. launchctl load unload, plist.

, , grepping launchctl list , , .

+8

launchctl list , - ... 0 -s... , .... -1, -251, ... ... startd ... launchctctll " " - 10 ..... , .

-w.... plist , , (, , ) . -w plist /var/db/launchd, , , . , "" XML Plist... , , , , ...

, overrides.plist tat var , ... , . , , , ...

+1

All Articles