16

On OS X Yosemite (10.10), is there any way to remove the enabled/disabled override setting for a service?

For example, to permanently disable non-existent service 'test' for root, do this:

sudo launchctl disable user/0/test

Check that it has been added to the disabled list:

sudo launchctl print-disabled user/0

Result:

disabled services = {
    "test" => true
}
login item associations = {
}

Now, how can I delete "test" from the disabled services list?

(I know I can enable it, but I just want to remove the entry entirely.)

Note:

If I reboot my computer, I see that the 'test' override has been added to a launchd disabled file:

sudo cat /var/db/com.apple.xpc.launchd/disabled.0.plist

Result:

<?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>test</key>
    <true/>
</dict>
</plist>

I have tried running this command to manually delete it from the .plist file:

sudo /usr/libexec/Plistbuddy /var/db/com.apple.xpc.launchd/disabled.0.plist -c Delete:test

This does delete it from the file, but it just comes back again when I reboot my computer. Any ideas?

Francis
  • 259
  • 1
  • 2
  • 11
  • Here is a discussion on similar topic: http://comments.gmane.org/gmane.comp.sysutils.launchd.devel/117 – andrey.s Sep 01 '15 at 13:56

4 Answers4

10

It seems like the nature of the info that used to be in overrides.plist has changed..

According to launchctl's man page for the "legacy" load / unload sub-commands..

-w Overrides the Disabled key and sets it to false or true for the load and unload subcommands respectively. In previous versions, this option would modify the configuration file. Now the state of the Disabled key is stored elsewhere on- disk in a location that may not be directly manipulated by any process other than launchd.

I guess now... the info is stored in the /var/db/com.apple.xpc.launchddirectory.

The contents of mine contained several plists.

config disabled.0.plist disabled.200.plist ... disabled.501.plist ... disabled.migrated loginitems.0.plist ... loginitems.501.plist ...

In this case, the file names are referring to the different Users' id's (501 being mine, 0 being root). Changing the keys in these files (as root, obviously) SHOULD remove the corresponding overrides with dark-overlord launchd.

If not, try editing these same files while booted to recovery, or some other drive - so as you can mess with them whilst launchd is not running/relentlessly trying to be boss.

Alex Gray
  • 16,007
  • 9
  • 96
  • 118
5

I was able to do this using Single User Mode. The steps are:

  1. Shut down your computer.
  2. On startup, enter single-user mode (Command + S).
  3. From the command line, type /sbin/mount -uw /
  4. Edit the appropriate /var/db/com.apple.xpc.launchd/disabled.*.plist file, removing disabled items, as desired.
  5. Type exit.
Gary
  • 4,426
  • 1
  • 22
  • 19
4

I've just solved this kinda problem with LaunchControl on yosemite… its a must have amazing little GUI for managing your daemons and agents on OSX. It has a lot of features… So just install it with cask

$ brew cask install launchcontrol

then find your service (under Use Agents or Global Daemons or whatever… ) in the list on the left.

Select it and in the main menu go to Job=>Override Disabled key=>Always False

Then reboot and check... Should work!

Drew
  • 594
  • 10
  • 25
  • 1
    What you are describing is how to permanently enable a service using LaunchControl. This is not what the poster asked. What he is looking for is Job>Override Disabled Key>Don't Override, which does not yet work on OSX Yosemite. – LCC Sep 12 '15 at 09:04
  • 1
    @LCC I reported this bug/my solution to support@soma-zone.com, the developer of LaunchControl (which rocks) – Alex Gray Oct 11 '15 at 06:42
  • 1
    @LCC BTW, the developer reported a `won't fix`/`can't fix` status re: this _un-feature_. – Alex Gray Mar 18 '16 at 19:53
  • 3
    Maybe worth noting that LaunchControl (https://www.soma-zone.com/LaunchControl) is commercial software and requires a paid license to be able to save changes. Lingon (https://www.peterborgapps.com/lingon) is another alternative for the same and also requires purchase of a license. – Julian D. Jun 05 '20 at 09:30
2

The configuration-files/scripts used by 'launchctl' are located in:

# Location of the LaunchAgents which run under the user own name (and is logged in).
$ cd $HOME/Library/LaunchAgents

# Location for the Deamons for running jobs without logged in user.
$ cd /Library/LaunchDaemons

# Location for the LaunchAgents which run as root when the user is logged in.
$ cd /Library/LaunchAgents

The following quick-and-easy commands for the XML-scripts (ending on .plist) are (assuming you are in one of the above listed directories and you may need a sudo):

# Loads the specified configuration file.  
# Jobs that are not on-demand will be started as soon as possible.
$ The -w option overrides the disabled setting.
# The -F option forces the loading and ignores the Disabled key.
$ launchctl load <script-name.plist>

# Unloads the specified configuration file from the current started session.
$ The -w option overrides the disabled setting.
# The -F option forces the loading and ignores the Disabled key.
$ launchctl unload <script-name.plist>

# Removes the specified configuration from the list and does not appear after rebooting
$ launchctl remove <script-name.plist>

See the man page for launchctl at https://ss64.com/osx/launchctl.html for details.

silverwind
  • 3,296
  • 29
  • 31
Harm
  • 787
  • 7
  • 11