Search code examples
macosmongodblaunchd

How to identify the source of what com.apple.launchd is attempting to run


The system log on my Mac Mini is showing this error in the system log:

Mar  7 17:51:18 My-Mac-mini com.apple.launchd[1] (org.mongodb.mongod[432]): posix_spawn("/opt/local/bin/mongod", ...): No such file or directory
Mar  7 17:51:18 My-Mac-mini com.apple.launchd[1] (org.mongodb.mongod[432]): Exited with code: 1
Mar  7 17:51:18 My-Mac-mini com.apple.launchd[1] (org.mongodb.mongod): Throttling respawn: Will start in 10 seconds

I have install MONGODB using Brew, and it works properly.

I have used LOCATE to attempt to track the source of the launching PLIST (I guess).

How do I track the source of what Apple's "launchd" is attempting to run?


Solution

  • You can search the LaunchDaemons folders for that job label:

    grep -Rl ">org\.mongodb\.mongod<" /System/Library/LaunchDaemons /Library/LaunchDaemons
    

    (Note: the backslashes and angle-brackets in the search string are needed to avoid false matches, and if you don't have them wrapped in double-quotes, you'll get unexpected results.)

    If it's installed using the standard conventions, it should be in /Library/LaunchDaemons/org.mongodb.mongod.plist, but this command should find it whatever it's named.

    Once you've found it, you can disable it with:

    sudo launchctl unload -w /Library/LaunchDaemons/org.mongodb.mongod.plist
    

    (Or whatever the actual file path is.) If you want, you can also remove the file, but the -w option makes the unload permanent so that isn't really necessary.