Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

launchd/launchctl disabled key and list option

Hi Community,

what does the disabled key, stored in a launchd plist file or in SL stored in /var/db/launchd.db/com.apple.launchd/overrides.plist, exactly means? It seems that a job run even if the disabled key is set to true or 1.

And if the disabled key is set, I've to load/unload the script by using launchctl explicit with the -w option but the state of the disabled key doesn't change but the script is active if load is used or rather inactive if unload is used.

Another question is why a scheduled task, launched by launchd, isn't displayed with 'launchctl list' even though my script is loaded successful with 'launchctl load'

Thx in advance & Bye Tom

2009 MacPro; 2010 MacBookPro; 2009 MacMini; iPhone; iPod; iWhatEver, Mac OS X (10.6.4)

Posted on Nov 2, 2010 2:10 PM

Reply
6 replies

Nov 2, 2010 7:26 PM in response to prontosystems

The overrides file you refer to only applies to root launchd jobs. If you change the disabled state of a per-user launchd job, the overrides file for that user is modified.

I don't understand the second paragraph of your message.

If you run "launchctl list" as a non-root user, you see only the active launchd jobs for that user. If you run it as root, you see only the root launchd jobs.

Nov 3, 2010 2:51 AM in response to Linc Davis

Hi,

the second question was for what the disabled key is used? It doesn't matter if I load or unload a script, the disabled key is always set. I can't see the sense of this key.

But the problem with the overrides file isn't answered too at this time. I placed a launchd start script into /Library/LaunchDaemons, of course the owner is root, I rebooted the system, the start script became executed during the system startup but there is no entry of this script in /var/db/launchd.db/com.apple.launchd.overrides.plist. I've to execute the defaults command with sudo, the script is owned by root, therefor an entry of this script should be located in this overrides file. But it isn't.

Thanks for your attention & Bye Tom

Nov 3, 2010 6:11 AM in response to prontosystems

A launchd plist can include an optional key with the name "Disabled" and value of "true" or "false" (the default.) If the key exists and has the value "true," the plist will be ignored by launchd when it processes the items in its directory. The overrides.plist file can override the "Disabled" key in a launchd plist.

For example, suppose you create a new file at ~/Library/LaunchAgents/foo.plist that has the "Disabled" key set to "false" (or not set at all.) The job will be loaded the next time you log in, or immediately if you enter "launchctl load ~/Library/LaunchAgents/foo.plist". No change will be made to your overrides.plist, because nothing is overridden.

If the "Disabled" key in foo.plist is set to "true," then the plist won't be loaded when you log in or when you enter the above command. Again, no change is made to overrides.plist.

If you enter "launchctl load -w ~/Library/LaunchAgents/foo.plist" then two things will happen. First, foo.plist will be loaded immediately regardless of the value of the "Disabled" key. Second, an entry will be created in your overrides.plist file overriding the value of "Disabled" key in foo.plist. The job will then load automatically at login until you change that entry by entering "launchctl unload -w ..."

Nov 3, 2010 10:24 AM in response to Linc Davis

Hi,

thank you very much, this was really a very interesting and detailed explanation. And this is an explanation too for the stupid comment in the manpage of launchctl:

Overrides the Disabled key and sets it to false. In previous versions, this option would modify the configuration file. Now the state of the Disabled key is stored elsewhere on-disk.


I thought why can't they write, that the disabled state is stored in the overrides.plist instead it "is stored elsewhere on disk..."? Because it is really stored elsewhere on disk! The overrides.plist isn't the place where the state of the disabled key is stored but it is the place where the items are listed who have an ignored disabled key state. This was one the points I totally misunderstood.

But one last question please. If i remember the characertistics of this state in the override.plist correct, the disabled state won't become changed if I use either the load -w or unload -w command. But in the overrides.plist are entrys listed with a disabled "Disabled key" (0 instead 1) what are they doing in the overrides.plist?

Thx you very much for your attention & Bye Tom

launchd/launchctl disabled key and list option

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.