14

OS X Yosemite (10.10) で、サービスの有効/無効のオーバーライド設定を削除する方法はありますか?

たとえば、ルートに対して存在しないサービス「test」を永続的に無効にするには、次のようにします。

sudo launchctl disable user/0/test

無効リストに追加されていることを確認します。

sudo launchctl print-disabled user/0

結果:

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

では、無効なサービスのリストから「test」を削除するにはどうすればよいですか?

(有効にできることはわかっていますが、エントリを完全に削除したいだけです。)

ノート:

コンピューターを再起動すると、「test」オーバーライドがlaunchd disabledファイルに追加されていることがわかります。

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

結果:

<?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>

.plistこのコマンドを実行して、ファイルから手動で削除しようとしました:

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

これによりファイルから削除されますが、コンピューターを再起動すると再び表示されます。何か案は?

4

4 に答える 4

9

以前にあった情報の性質overrides.plistが変わったようです..

「レガシー」/サブコマンドlaunchctlのページによると..manloadunload

-wDisabled キーをオーバーライドし、load サブコマンドと unload サブコマンドに対してそれぞれ false または true に設定します。以前のバージョンでは、このオプションは構成ファイルを変更していました。現在、Disabled キーの状態は、launchd 以外のプロセスによって直接操作されない可能性があるディスク上の別の場所に保存されます。

私は今推測しています...情報は/var/db/com.apple.xpc.launchdディレクトリに保存されています。

私のコンテンツにはいくつかのplistが含まれていました。

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

この場合、ファイル名はさまざまなユーザーの ID を参照しています501( mine root )。これらのファイルのキーを (明らかに root として) 変更すると、対応するオーバーライドを dark-overlord で削除する必要があります。0launchd

そうでない場合は、リカバリまたは他のドライブで起動している間にこれらの同じファイルを編集してみてくださいlaunchd

于 2015-09-23T03:56:00.127 に答える
2

「launchctl」で使用される構成ファイル/スクリプトは、次の場所にあります。

# 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

次の XML スクリプト (.plist で終わる) の簡単で簡単なコマンドは次のとおりです (上記のディレクトリのいずれかにいて、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>

詳細については、 https: //ss64.com/osx/launchctl.html にある launchctl のマニュアル ページを参照してください。

于 2019-03-11T15:25:57.143 に答える