Some time ago, I posted about starting Apache automatically when macOS 10.12 Sierra starts, using the launchctl command to add Apache to the launchd Launch Daemon/Agent Manager. For those familiar with Windows, this is akin to managing Windows Services.

Previously, I mentioned that to automatically start Apache, run the command:

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

And to stop Apache from auto-starting:

sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist

Note that there is no output most of the time so it's hard to confirm you got it right!

As can be seen, launchctl gets the definition from a .plist to add Apache as a "daemon". A daemon serves all users on the machine system-wide (a bit like the Windows registry HKLM runs services for the "Local Machine"), while agents run per-user (a bit like HKCU for the "Current User").

To list all launch daemons and agents, use launchctl list, but since I want to ignore any Apple provided processes, I use:

launchctl list | grep -v apple

I get the list below. Note that some items are running processes manually started (e.g. Firefox in my case), and other items are started via System Preferences > Users & Groups > Login Items (e.g. itsycal in my case). The PID - means that the job is loaded but not running (e.g. only the jamf agent is running in my case):

PID Status  Label
12345   0   org.mozilla.firefox.9876
-   0   org.mozilla.firefox.8765
-   78  com.abc.abc123
-   0   com.openssh.ssh-agent
2345    0   com.mowglii.ItsycalApp.7654
-   0   com.microsoft.VSCode.ShipIt
-   0   com.cisco.anyconnect.gui
-   0   com.box.box-notes.ShipIt
-   0   com.oracle.java.Java-Updater
-   0   com.google.keystone.system.agent
3456    0   com.jamfsoftware.jamf.agent

I learnt a lot from launchd.info and Paul Annesley's post Mac OS X: Launchd is cool.

There are five locations where launchd .plist files reside:

Location Description
~/Library/LaunchAgents Per-user agents provided by the user.
/Library/LaunchAgents Per-user agents provided by the administrator.
/Library/LaunchDaemons System-wide daemons provided by the administrator.
/System/Library/LaunchAgents Per-user agents provided by macOS.
/System/Library/LaunchDaemons System-wide daemons provided by macOS.

I want to get only .plists for daemons and agents that aren't part of macOS, so:

ls -h ~/Library/LaunchAgents /Library/LaunchAgents/ /Library/LaunchDaemons/ | grep -v apple

I get:

/Library/LaunchAgents/:
com.cisco.anyconnect.gui.plist
com.jamfsoftware.jamf.agent.plist
com.oracle.java.Java-Updater.plist
com.google.keystone.agent.plist

/Library/LaunchDaemons/:
BESAgentDaemon.plist
com.cisco.anyconnect.ciscod.plist
com.cisco.anyconnect.vpnagentd.plist
com.jamfsoftware.ibm.netservice.plist
com.jamfsoftware.jamf.daemon.plist
com.jamfsoftware.startupItem.plist
com.jamfsoftware.task.1.plist
com.microsoft.autoupdate.helper.plist
com.microsoft.office.licensingV2.helper.plist
com.oracle.java.Helper-Tool.plist
com.google.keystone.daemon.plist
org.virtualbox.startup.plist

/Users/[[user]]/Library/LaunchAgents:
com.abc.abc123.plist
org.virtualbox.vboxwebsrv.plist

In my case, I discovered a launch agent, which I have fictitiously renamed com.abc.abc123.plist in the example above, that pointed to a Preference Pane that no longer existed! I think I removed it by right clicking on the icon in System Preferences. The corresponding Status reported by launchctl list was 78 probably indicating a misconfiguration error.

I recognize most items in the list, so I'm good and decided to make no changes. E.g. My organization uses jamf for device management and BigFix (BES) for patching.

Aside

On a side note, Java 7 used a rather strange auto-update mechanism via launchd, that ignores the update setting via System Preferences > Java > Update. I don't know if it applies to Java 8.

One can remove Java by just deleting files, as described in Oracle's guide: How do I uninstall Java on my Mac?. I've never tried it since I need Java, but I'm curious if the daemon and agent get left behind. The commands provided by Oracle are:

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Java

Related Posts

Newer Post Older Post