Mac launchd: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=
 
* https://www.launchd.info
* https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
* https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html


Line 11: Line 11:


<code>[[Brew|brew]]</code> can configure services to be started by <code>launchd</code>.
<code>[[Brew|brew]]</code> can configure services to be started by <code>launchd</code>.
<code>launchd</code> identifies services by their "labels" (example: "com.apple.bluetoothd").
=Configuration=
Files in:
<code>~/Library/LaunchAgents</code>


=Operations=
=Operations=
==Enable a Service to Start at Boot==
The following command will configure <code>launchd</code> to start the program designated by <code><name></code> at boot. It does not start it immediately.
<syntaxhighlight lang='bash'>
launchctl enable <name>
</syntaxhighlight>
==Prevent a Service to Start at Boot==
A program that was previously enabled to start at boot with <code>launchctl enable</code> can be prevented to start at boot with:
<syntaxhighlight lang='bash'>
launchctl disable <name>
</syntaxhighlight>
==Start a Service==
<syntaxhighlight lang='bash'>
launchctl start <name>
</syntaxhighlight>
==Stop a Service==
<syntaxhighlight lang='bash'>
launchctl stop <name>
</syntaxhighlight>


==Show Status of a Service==
==Show Status of a Service==
Line 19: Line 49:
launchctl list com.apple.bluetoothd
launchctl list com.apple.bluetoothd
</syntaxhighlight>
</syntaxhighlight>
==Stop a Service==


=Organizatorium=
=Organizatorium=

Latest revision as of 18:09, 8 October 2024

External

Internal

Overview

brew can configure services to be started by launchd.

launchd identifies services by their "labels" (example: "com.apple.bluetoothd").

Configuration

Files in: ~/Library/LaunchAgents

Operations

Enable a Service to Start at Boot

The following command will configure launchd to start the program designated by <name> at boot. It does not start it immediately.

launchctl enable <name>

Prevent a Service to Start at Boot

A program that was previously enabled to start at boot with launchctl enable can be prevented to start at boot with:

launchctl disable <name>

Start a Service

launchctl start <name>

Stop a Service

launchctl stop <name>


Show Status of a Service

launchctl list com.apple.bluetoothd

Stop a Service

Organizatorium

System httpd keeps starting in foreground

I fixed with:

launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

but I don't know what determined it to suddenly start, and why the above command worked.

Is a Service Running?

launchctl list | grep com.something.someprocess