How to know a specific launchd.plist file location?

后端 未结 7 1019
天涯浪人
天涯浪人 2021-01-31 10:25

Is it possible to know the .plist file location which is loaded into the launchctl command?

The label name is listed with \"launchctl list\" and its contents can be view

7条回答
  •  半阙折子戏
    2021-01-31 10:50

    This question might have has no answer! It seems that not everything in launchctl list will have a plist file at all.

    As mentioned, launchctl dumpstate will give you tons of info on things including the plist path, if it exists.

    You can run this command to approximately see a list of everything running and its plist path.

    launchctl dumpstate | grep -A4 " = {" | grep -B 3 -A 3 -E "active count = [1-9]"
    

    (Though this also seems to include other programs running that aren't daemons managed by launchd?)

    The agents/daemons will have a path field underneath their identifier. Usually, the paths point to a plist file in the standard 5 locations described by Reed's answer. However, it doesn't have to be. For example Steam loads a launchctl service from a nonstandard location.

    ➜ launchctl dumpstate | grep -A4 " = {" | grep -B 3 -A 3 -E "active count = [1-9]"  | grep valve
    com.valvesoftware.steam.ipctool = {
        path = /Users/chris/Library/Application Support/Steam/com.valvesoftware.steam.ipctool.plist
    

    Fortunately that practice isn't too popular so searching the standard locations is usually sufficient.

    But that's not the trickiest thing. I don't know the specifics but it appears that launchctl services can be loaded without a corresponding plist file at all. For example, this is what dumpstate says for the 1Password helper daemon.

    ➜ launchctl dumpstate | grep -A4 " = {" | grep -B 3 -A 3 -E "active count = [1-9]"  | grep -A4 "onepassword7-helper = {"
    2BUA8C4S2C.com.agilebits.onepassword7-helper = {
        active count = 5
        path = (submitted by smd.1154)
        state = running
    

    I don't know what "submitted by smd" really means, but it boils down to even if I see a helper in launchctl list there might not be any plist on the filesystem. Because of this I don't know how to launchctl unload this service because unload requires a plist path! And since this process is managed by launchd, even if I pkill -9 onepassword7-helper, launchd sees that the process stopped and starts it right back up again.

    (fortunately for this particular 1Password example, if you hold ^ and when clicking Quit 1Password, a special "Quite 1Password Completely" option will appear)

提交回复
热议问题