How to know a specific launchd.plist file location?

后端 未结 7 935
天涯浪人
天涯浪人 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:57

    This issue comes up a lot and unfortunately locate and mdfind both don't show results from the appropriate directories on my system. I put the following function in my .bashrc so I could quickly search the directories where launchctl looks for plist files.

    launchctlFind () {
        LaunchctlPATHS=( \
            ~/Library/LaunchAgents \
            /Library/LaunchAgents \
            /Library/LaunchDaemons \
            /System/Library/LaunchAgents \
            /System/Library/LaunchDaemons \
        )
    
        for curPATH in "${LaunchctlPATHS[@]}"
        do
            grep -r "$curPATH" -e "$1"
        done
        return 0;
    }
    

    Note that this only checks in the directories where launchctl looks for files at boot-up and login. It may not find everything because jobs can be manually loaded by the user and/or other processes.

    UPDATE: For those running macOS 10.12.6 or higher I would recommend using Joel Bruner's solution below.

提交回复
热议问题