Page History

launchd

Nigel Stanger edited this page on 30 Dec

Clone this wiki locally

Adding jobs

  1. Create appropriate plist file.
  2. Put it in:
    • /Library/LaunchAgents for user-specific jobs
    • /Library/LaunchDaemons for system-wide jobs
  3. Load the job:
    • launchctl load /Library/LaunchAgents/job.plist for user-specific jobs
    • sudo launchctl load /Library/LaunchDaemons/job.plist for system-wide jobs

Setting environment variables

/bin/launchctl setenv VARIABLE "value"

Job not loading

For example, error 78 “Function not implemented”. This generally implies a configuration error in the script being run. Check:

  • script permissions (must be executable)
  • shebang line
  • com.apple.quarantine attribute randomly applied (use xattr -d com.apple.quarantine file to remove)