MacOS Services
macOS Services (launchd)
Description
On macOS, `launchd` is the system-wide service manager that starts, stops, and manages daemons and agents. You can interact with it using the `launchctl` command-line tool.
Services are defined in two main types:
- LaunchAgents: These are executed for a specific user only when that user logs into a graphical session.
- LaunchDaemons: These are invoked when the system boots and run independently of any user session.
Service File Locations (Namespaces)
The property list (`.plist`) files that define how a service should run are stored in specific directories:
System-Wide (Administrator-provided)
- `/Library/LaunchDaemons`: For system-wide daemons.
- `/Library/LaunchAgents`: For agents that should be available to all users.
User-Specific
- `~/Library/LaunchAgents`: For agents provided by and running as the current user.
Managing Services with `launchctl`
You can control services using the `launchctl` command.
To enable and start a service:
launchctl load /path/to/your/service.plist
To disable and stop a service:
launchctl unload /path/to/your/service.plist