SPB Git
6.2 KB · 47 lines json
1{2  "slug": "launchd",3  "name": "launchd",4  "aliases": ["launchctl", "LaunchAgents", "LaunchDaemons"],5  "vendor": { "name": "Apple Inc.", "slug": "apple", "website": "https://developer.apple.com/" },6  "homepage_url": "https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html",7  "docs_url": "https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html",8  "product_type": "service",9  "product_status": "active",10  "summary": "macOS's built-in service manager that starts, supervises and schedules daemons and per-user agents from property-list job definitions",11  "description": "launchd is the init and service-management system of macOS, the first process started by the kernel and the component responsible for launching every daemon, agent and scheduled job on the system. Apple documents it in the Daemons and Services Programming Guide (now in the Documentation Archive) and in the `launchd` and `launchd.plist` manual pages; the `launchctl` command loads, unloads, starts and inspects jobs.\n\nA job is described by an XML property list placed in one of a few directories: `/Library/LaunchDaemons` for system-level daemons that run as root or a configured user regardless of who is logged in, and `/Library/LaunchAgents` or `~/Library/LaunchAgents` for per-user agents that start at login. Keys such as `Label`, `ProgramArguments`, `RunAtLoad`, `KeepAlive`, `StartInterval`, `StartCalendarInterval`, `WatchPaths` and `Sockets` define when the job runs and whether launchd should restart it. Because launchd owns the sockets and relaunches crashed processes, programs written for it should not daemonize themselves.\n\nOn a Mac used as a server or cluster node, launchd is what keeps long-running services alive across reboots: Homebrew's `brew services`, PM2's `pm2 startup` and many monitoring agents simply generate launchd plists. Daemons are the right choice on machines without a graphical login session; agents are needed when a job must interact with the user's session.\n\nCaveats: the plist format is verbose and error-prone, debugging relies on `launchctl print` and log files rather than a friendly UI, the `launchctl` syntax changed between the legacy `load`/`unload` and the newer `bootstrap`/`bootout` domain-based commands, and Apple's conceptual guide has not been updated since 2016.",12  "capabilities": ["Launch at boot (daemons) or at login (agents)", "Keep-alive supervision and automatic restart", "Interval and calendar scheduling without cron", "Path and directory watching triggers", "Socket activation with on-demand launch", "Per-job environment, user, working directory and stdout/stderr redirection"],13  "workflows": ["Keep a Node or Python service running on a headless Mac Studio", "Run a nightly backup script with StartCalendarInterval", "Start a process whenever files land in a watched folder", "Replace a user cron job with a LaunchAgent"],14  "advantages": ["Built into every macOS install; nothing to add", "Survives reboots and crashes without external supervisors", "Single mechanism for scheduling, supervision and socket activation"],15  "limitations": ["Verbose XML plists and opaque error messages", "Two generations of launchctl syntax cause confusion", "Agents need a logged-in session; daemons cannot touch the GUI", "Official conceptual documentation is archived and dated"],16  "prerequisites": ["macOS", "Administrator rights for system-level daemons"],17  "audiences": ["macOS administrators and power users", "Developers deploying services on Mac servers", "Anyone replacing cron on a Mac"],18  "alternatives": ["pm2", "docker", "ansible"],19  "comparison_notes": "PM2 is a user-space process manager for Node (and other) applications with a friendlier CLI, log handling and clustering; on macOS it ultimately registers itself with launchd to survive reboots, so the two are layered rather than exclusive. Docker supervises processes inside containers and restarts them by policy, which isolates dependencies but adds a VM layer on macOS. Ansible can write launchd plists across a fleet but is a configuration tool, not a supervisor. Compared with cron, launchd adds supervision and event triggers and is what Apple maintains going forward.",20  "categories": [{ "slug": "macos-automation", "primary": true }, { "slug": "infrastructure-provisioning" }],21  "tags": ["macos", "process-supervision", "scheduling", "daemons", "cli", "apple"],22  "use_cases": ["monitor-services", "host-web-apps", "schedule-jobs"],23  "operating_systems": ["macos"],24  "execution_modes": ["local"],25  "interfaces": ["cli"],26  "deployment_models": ["desktop", "on-premises"],27  "integrations": ["Homebrew services", "PM2 startup", "Shortcuts and Automator (via scripts)"],28  "data_formats": ["XML property lists (.plist)"],29  "languages": [],30  "source_model": "proprietary",31  "pricing_model": ["free"],32  "self_hostable": true,33  "sources": [34    { "url": "https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html", "type": "official_site", "title": "Daemons and Services Programming Guide – Introduction", "supports": ["name", "summary", "description"], "checked_at": "2026-11-02", "note": "Apple Documentation Archive; last updated 2016" },35    { "url": "https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html", "type": "official_docs", "title": "Creating Launch Daemons and Agents", "supports": ["capabilities", "workflows", "limitations"], "checked_at": "2026-11-02" },36    { "url": "https://support.apple.com/guide/terminal/script-management-with-launchd-apdc6c1077b-5d5d-4d35-9c19-60f2397b2369/mac", "type": "official_docs", "title": "Script management with launchd in Terminal on Mac", "supports": ["capabilities", "workflows"], "checked_at": "2026-11-02" }37  ],38  "confidence": "high",39  "uncertainty_note": "Apple's conceptual guide is archived (2016). Current behavior of launchctl subcommands is documented only in the manual pages shipped with macOS.",40  "discovery_method": "editorial-research",41  "depth": "deep",42  "editorial_status": "reviewed",43  "visibility": "public",44  "featured": false,45  "author": "batch-C"46}47
Files · laptop-initial-20261102
Menu

Theme