13

After installing Autodesk Smoke, I have two httpd processes running all the time, and I'd like to stop them. When I use sudo killall httpd, they stop and are restarted right away. Activity Monitor shows that the parent process is launchd, but how do I determine which agent or daemon is starting it so I can disable it?

launchctl list | grep httpd shows these results:

302 -   0x7f94ea700dd0.anonymous.httpd  
92  -   org.apache.httpd

I look in /System/Library/LaunchDaemons/org.apache.httpd.plist and it shows the following. You can see it's set to disabled. The other launchd item with a weird name doesn't show up in a filesystem search, so I have no idea what it is.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <true/>
    <key>Label</key>
    <string>org.apache.httpd</string>
    <key>EnvironmentVariables</key>
    <dict>
        <key>XPC_SERVICES_UNAVAILABLE</key>
        <string>1</string>
    </dict>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/sbin/httpd</string>
        <string>-D</string>
        <string>FOREGROUND</string>
    </array>
    <key>OnDemand</key>
    <false/>
</dict>
</plist>
2
  • I learned from Autodesk that I can stop the process with /usr/sbin/apachectl stop but I still don't know how to disable it after every reboot.
    – Elliott
    Dec 17, 2013 at 8:50
  • (Late comment, I know!) Two possible leads to stop launchd from starting it again: (i) launchctl unload (though I don't know if this needs you to specify the path to the plist), (ii) If it's in your loginitems, use the System Preferences tool --> "Users and Groups" --> "Login Items" --> Delete offending entry if found.
    – Vivek
    Mar 18, 2015 at 3:35

4 Answers 4

6

You can grep the output of launchctl list for the pid:

$ pgrep -fl foo
40679 bash /tmp/foo
$ launchctl list|grep 40679
40679   -   com.example.foo

Then for example look for a file named com.example.foo.plist in ~/Library/LaunchAgents/, /Library/LaunchAgents/, or /Library/LaunchDaemons/.

Edit: the Disabled key can be overridden in /var/db/launchd.db/com.apple.launchd/overrides.plist, which is modified when launchctl load -w is run as root, or in /var/db/launchd.db/com.apple.launchd.peruser.$UID/overrides.plist, which is modified when launchctl load -w is run as the user.

If the Apache plist that comes with OS X was enabled, you can disable it by running sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist.

3
  • I got the PID, then grepped launchctl but found nothing with that number.
    – Elliott
    Dec 7, 2013 at 17:38
  • Actually try using sudo launchctl list. launchctl list only seems to include jobs loaded by the user launchd process.
    – Lri
    Dec 8, 2013 at 6:55
  • OK that makes sense, thank you. But didn't really solve the problem... I added more details to the question.
    – Elliott
    Dec 8, 2013 at 17:43
1

Based on the label value (e.g. org.apache.httpd), you can try to find the .plist using the following command:

find /System/Library/Launch* /Library/Launch* ~/Library/Launch* -name '*.plist' -print -exec /usr/libexec/PlistBuddy -c "Print Label" {} ';' | grep org.apache.httpd -A1

To find what started the process, check its parent PIDs, e.g.

ps -f $(launchctl list | grep org.apache.httpd | grep -o '^[0-9]\+')

Or use pstree command by specifying PID manually, e.g.

pstree 92
1
  • pstree works pretty well!
    – Sati
    May 22, 2020 at 0:20
0

This gives you a list of all job definitions referring to httpd.

grep -lR httpd /System/Library/Launch*/ /Library/Launch*/ ~/Library/LaunchAgents/
3
  • Good idea, but did not solve the problem. There is only one result, and it's disabled. I added more details to the question.
    – Elliott
    Dec 8, 2013 at 17:45
  • 1
    Just because it is disabled does not mean that it has not been started. The Disabled key may be overridden by the overrides.plist files in/below /var/db/launchd.db/. Also a disabled job may still be manually (not automatically during the boot/login process) started.
    – LCC
    Dec 9, 2013 at 2:06
  • Thanks, I did not know about that. I tried grep -rn apache /private/var/db/launchd.db and found only one result. It's disabled. I need to figure out how this service is being started and how to truly disable it.
    – Elliott
    Dec 9, 2013 at 7:27
0

The behaviour of launchctl has changed in that if a service is forcibly enabled, it will not modify the contents of the source .plist, but a separate directory (which you shouldn't modify). Check the man page for launchctl, and the "-w" option under the "load" command. So, simply examining the file won't necessary tell you if its disabled or not. Clearly its not disabled :)

Try "launchctl unload -w org.apache.httpd.plist". If that works for you, then you'll still be able to start it on demand with "launchctl start org.apache.httpd.plist"

If that doesn't work, try "launchctl remove org.apache.httpd.plist" which will not let you manually start.

You must log in to answer this question.

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