2

I found a bunch of processes being launched using launchd using ps aux -o ppid.

However, launchd also has plist files associated with a process launched with it, and its spread across a lot of directories.

Is it possible to find out whats the plist file that is associated with a process launched by launchd?

1 Answer 1

3

Use the launchctl utility.

Run launchctl list to get an overview of all loaded daemons and their PIDs (if they're running). In this list you can grep for the PID to find the label corresponding to the process you want to investigate.

Executing launchctl print gui/$(id -u)/LABEL shows a bunch of information, and printed at the top you can find the path to the .plist, if the process daemon is loaded from a .plist.

Example:

$ launchctl list                         
PID Status  Label
630      0  com.apple.Finder
...


$ launchctl print gui/$(id -u)/com.apple.Finder
...
    path = /System/Library/LaunchAgents/com.apple.Finder.plist
...
2
  • In my answer I use the login domain target, I'm not sure if there's a more universal or otherwise better way to access the service target, using the system domain doesn't work. Commented Aug 3, 2022 at 10:06
  • 3
    You need to use the correct domain for the particular agent/daemon you want info about. Some agents are in the user domain rather than GUI, so you'd use e.g. launchctl print user/$UID/com.apple.WeatherService. For daemons, you list them with sudo launchctl list (running it as root automatically targets daemons instead of agents), and print their info with e.g. launchctl print system/com.apple.backupd. Commented Aug 3, 2022 at 17:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .