Create a launchd system daemon on macOS that runs as root and restarts automatically on failure

domain: developer.apple.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create a plist at /Library/LaunchDaemons/com.example.mydaemon.plist owned by root:wheel with permissions 0644.
  2. Set the required keys: Label matching the filename without .plist, ProgramArguments as an array of the executable and its arguments, and KeepAlive set to true to restart the process if it exits.
  3. Add StandardOutPath and StandardErrorPath pointing to log files under /var/log/ for output capture.
  4. Load the daemon: sudo launchctl load /Library/LaunchDaemons/com.example.mydaemon.plist
  5. Check daemon status: sudo launchctl list | grep com.example.mydaemon — the PID column shows the running process ID.

Known gotchas

Related routes

Create a launchd user agent on macOS that runs a script on a recurring calendar schedule
developer.apple.com · 5 steps · unrated
modernize macOS launchd job management by replacing launchctl load/unload with bootstrap/bootout and print for domain-target introspection
developer.apple.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans