Mac launchd: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(8 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 6: Line 6:


* [[Mac#Subjects|Mac]]
* [[Mac#Subjects|Mac]]
* [[Brew]]


=Overview=
=Overview=


<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=
==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==
<syntaxhighlight lang='bash'>
launchctl list com.apple.bluetoothd
</syntaxhighlight>
==Stop a Service==


=Organizatorium=
=Organizatorium=
Line 16: Line 58:
I fixed with:
I fixed with:


<pre>
<syntaxhighlight lang='bash'>
launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
</pre>
</syntaxhighlight>


but I don't know what determined it to suddenly start, and why the above command worked.
but I don't know what determined it to suddenly start, and why the above command worked.
==Is a Service Running?==
<syntaxhighlight lang='bash'>
launchctl list | grep com.something.someprocess
</syntaxhighlight>

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