Remove an Agent from launchd

Mar 8, 2011 - 21 Comments

remove-launchd-service

The vast majority of Mac users won’t need to manually tweak launchd and launchctl, but there are times when you uninstall or stop using an app in Mac OS X and a service agent continues to needlessly load in launchd. This is annoying, but these rogue agents are easy to remove via the command line, so launch Terminal and away we go.

You’ll need to have some understanding and comfort of using the command line and Terminal to use this properly, making this ideal for more advanced users who have knowledge of launch daemons and how to track them down, which, sometimes, is just a matter of finding one in the Activity Monitor of Mac OS X, or by using the launchctl command we’ll discuss shortly. If you decide to reverse the modification, you can also load the service or daemon back into launchd using another command, which effectively undoes the initial removal step. Let’s get to it:

Removing Launch Agents & Services from launchd

Here is how to remove a service from launchd. Launch Terminal and then use the following syntax with the launchctl command:

launchctl remove name

For example, if I want to remove a service named “com.annoying.service” the syntax would be:

launchctl remove com.annoying.service

You may need to prefix the command with sudo in order to remove the service, in this case the command would be:

sudo launchctl remove com.annoying.service

With the sudo prefix you’ll have to enter an administrator password before the command will execute.

How to See What is Loaded in launhcd

You can also check what’s loaded into launchd by using the following command string:

launchctl list

This command lists all agents and jobs loaded into launchd, allowing you to easily manipulate the agents that are running. Because it dumps a ton of information onto the screen at once, you may want to pipe it through the more or less commands like so:

launchctl list |more

This lets you hit the return key to more slowly navigate through the list.

If you know generally the service you’re looking for, you can also use “grep” to find the precise agents service, let’s use ‘mdworker’ as an example::

launchctl list |grep mdworker

This would report back only the following launchagents:

- 0 com.apple.mdworker.sizing
- 0 com.apple.mdworker.single
- 0 com.apple.mdworker.shared
- 0 com.apple.mdworker.mail
- 0 com.apple.mdworker.lsb
- 0 com.apple.mdworker.isolation
- 0 com.apple.mdworker.bundles
- 0 com.apple.mdworker.32bit

For some services, dumping the list may also show the PID (process ID) of the active service as well.

Loading an Agent Back into launchd

If you decide you want to reenable and reload a service back into launchd, use the ‘load’ flag like so:

launchctl load com.example.service.to.load

Some agents will load instantly without issue. For others, you may need to reboot the Mac before the loaded service will function as intended again, though sometimes logging out and back in is sufficient as well.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: David Mendez in Command Line, Mac OS X

21 Comments

» Comments RSS Feed

  1. Magic says:

    I love the terminal tips, keep em comin

  2. Justin says:

    What are some of the services that we should remove? Any service that would be slowing down the computer?

  3. albinoz says:

    NIce tips thanks but remove result ” launchctl remove error: No such process” ?

  4. Tim says:

    OK, this has come at the perfect time for me. At least, I thought it had.

    Every time I rouse my Macbook from sleep, I get an annoying process named ‘rastertobrother3′. This seems to be a process related to the CUPS driver for Brother peripherals (which I don’t use).

    I kill the process manually because it uses 100MB of RAM which I can’t afford to lose. But doing it manually every time is a MASSIVE PAIN.

    Here’s where it gets weird: the process doesn’t show up in launchctd list. The process ID is simply not there.

    What the hell? How do I kill this process once and for all?!

  5. albinoz says:

    Tim : Look in /Library/LaunchAgent and /Library/LaunchDeamon or maybe in /Library/StartupItems. SomeTimes they are in your Home library… have more speed ;)

  6. Tim says:

    Hmm. No files in LaunchAgents. And I don’t have either of the other folders :(

  7. Christian says:

    OMG Thank You! I was finally able to remove this MYSQL service.

  8. Michael Hines says:

    This worked perfectly removing Xquartz from the list. I use the open source opennx client and one day I decided to try Xquarts instead of X11.app and suddenly my NX client stopped working. When I tried this to remove Xquartz, my NX started working again. You’re a lifesaver.

  9. golook says:

    Thanks for the tip but I am having a similar experience as Albinoz.
    I have services that start with my computer that are also found in the launchctl list but I get the error message ” launchctl remove error: No such process”
    Anybody got a clue?
    I even tried sudo with my password.
    I have multiple accounts on my computer but after a new start none have run. Besides I am the only admin!
    questions, question
    hope someone hears these late on comments

  10. Tom! says:

    amazing!, but I still have a problem,
    I uninstalled long ago MacKeeper, but I think I did it the wrong way, so, at the console still displaying this:

    25/03/12 14:30:51 com.apple.launchd[1] com.apple.launchd (com.zeobit.MacKeeper.plugin.AntiTheft.daemon[65237]) posix_spawn(“/Library/Application Support/MacKeeper/MacKeeperATd”, …): No such file or directory

    I want to get rid of this, i tried with all those comand lines, but nothing happens, what should i do?

    • helper says:

      You’ll have to track down the “com.zeobit.MacKeeper.plugin.AntiTheft.daemon” file, it’s probably in the /Library/LaunchDaemons/ directory

  11. Skip L says:

    Thanks Helper for the tip!
    Had the same MacKeeper launching services console problem;

    com.apple.launchd[1] com.apple.launchd (com.zeobit.MacKeeper.plugin.AntiTheft.daemon[65237]) posix_spawn(“/Library/Application Support/MacKeeper/MacKeeperATd”, …)

    deleted the .plst file under my user/Library/ LaunchAgents and finally got rid of the pesky issue!

  12. Frankly says:

    exactly the sort of answer that i absolutely hate about some Mac users below ..

    “What are some of the services that we should remove? Any service that would be slowing down the computer?

    None. If you don’t have a reason to, don’t mess around with launchd”

    - what a smug, unhelpful, narrow-minded and insulting answer.. that is exactly the sort of mindset that real tech’s hate. LaunchD is there to tweak, the whole OS is tweakable, so shitty answers like ‘apple knows best’ is exactly the type of blinkered and philistine answer that makes my blood boil.

    There is even a app called ‘Lingon’ – which lets you tweak, add, remove, respawn and generally mess around with Launchd.. there are many services n OS X that you can do without, consume RAM, CPU and thus battery life and with running additional unwanted ‘services’ or ‘daemons for example which can expose vulnerabilities on an network level.
    For example addressbook, podcast uploader, pictd, quicklook, remote desktop, screen reader, samba, cups, spindump, backupd, applespell, spindump and postfix are just some of the stuff not running on my MacbookPro .. i dont need, want or use them, so they can go.

    Just Google carefully the service you’re interested in, AND
    be prepared to reinstall if the Mac doesn’t start up after removing / disabling these, and obviously back up all your data BEFORE you do thid, or before you reinstall.
    Some you can remove easily and will never notice, some you may never use, and yes, some will kill the OS, making it unbootable again, requiring you to reinstall OSX again over the top of your broken OS.. warning over.

    Anti-intellectual, paternal and insulting comments llke
    ‘dont touch it’ are a disease in the Apple community and should be stamped out and these people should actually learn about computer operating systems themselves before opening their mouths.

    The info is out there,
    try it,
    reinstall it,
    learn it,
    understand it,
    and pass it on.

    • David says:

      Not sure why you should feel so entitled to vitriol, but I suggest the likes of you are better off just leaving launchd alone =P

  13. Bob-O says:

    Any idea what launch puppies with “..anonymous..” in name are? See examples below (I’ve changed codes in case they’re revealing something about my system I don’t want known).

    Rather uncomfortable seeing such, like a virus or so.

    Some have process ID of launchd. There are several such in both sudo and user launchctl list.

    0x7f936fc058b0.anonymous.bash
    0x7f936ed2de90.anonymous.login

    Some have process IDs that aren’t listed in Activity Monitor.

    Several are attached to obvious processes, like

    0x7h035bd031d5.anonymous.WindowServer

    Thanks in advance

  14. ly2k says:

    Hi I know this thread is old, but…

    I am no Terminal guru, but I have seen different ways to unload/remove agents before.

    What is the difference between these two commands:

    launchctl remove com.apple.bookstoreagent
    launchctl unload -w com.apple.bookstoreagent

    • Paraspritey says:

      I know that “launchctl remove [agent]” removes the job from launchd, whereas “launchctl unload [agent]” will be reverted when you restart, however I don’t know how this plays into the -w flag at all.

      I’m not sure if you know, but you can access more information with the command “man launchctl”. Perhaps it is a bit more clear to you than it is to me.

  15. Barry says:

    Thanks worked like a charm.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates