Finding the true status of launchd jobs [closed]
launchctl list
launchctl bstree
These show which jobs are active, dormant or inactive, allegedly. I have never seen an inactive job personally. Even ones that I have tried to inactivate show as 'D'
Now, in /var/db/launchd.db there are textfiles that show, per user, which jobs are actually disabled, lamentably, the old -w switch was deprecated, and the Disabled key in the plist is only a default. I don't know why they would do such a thing, there seems to be no way to say definitively
"Service X is off."
It seems that running as root I should be able to ask what is on, and what is off. What am I doing wrong?
EDIT: What I was doing wrong was ignoring
/var/db/launchd.db/com.apple.launchd/overrides.plist
Which is the definitive place apparently for the current state of a daemon.
Handily, this means that the default will be in the plist files in /System/Launch* /Library/Launch* ~/Library/Launch* and one can just blow away ( errrm copy and move ) that directory and reboot to a default set. This worked for me recently.
The true status is whether a job is currently loaded or not.
Have a re-read of the launchd philosophy - items 4 and 1 explain that launchd waits till the last moment before starting the child task and that process will come and go with launchd timing, throttling and disabling tasks as needed.
These are all logged to system logging. top
and ps
will show you the current processes. I suppose you could simply attach launchd to a debugger if you need to know the exact state since the current code doesn't make a list to your liking.
The launchd GUI LaunchControl will give you a list of services along with their respective status. You can see if a job has been disabled by looking at the check box next to the job name. A colored check box indicates that the Disabled key has been overridden: a red checkbox stands for a permanently disabled job, a green one for a permanently enabled job.