OSX: Launchd Tips, Tricks and examples

root's picture

Launchd is designed to start System and Users daemon/agents located in the following places:

~/Library/LaunchAgents - Per-user agents provided by the user
/Library/LaunchAgents - Per-user agents provided by the administrator
/Library/LaunchDaemons - System-wide daemons provided by the administrator
/System/Library/LaunchAgents - Per-user agents provided by Mac OS X
/System/Library/LaunchDaemons - System wide daemons provided by MAC OS X

How to list all launchd services:

launchctl list
Example with grepping out the apple ones:

mini:~ root# launchctl list | grep -v com.apple
PID     Status  Label
-       0       org.calendarserver.agent
25553   0       org.postfix.master.passive
-       0       org.calendarserver.archive
-       0       org.cups.cupsd
-       0       com.bresink.system.privilegedhelper-tts
-       0       org.postfix.newaliases
-       0       com.openssh.sshd
-       0       ro.gz.vms
259     0       com.vix.cron
25428   0       com.openssh.sshd
129     0       ro.gz.bs
257     0       org.ntp.ntpd
-       0       org.calendarserver.relocate

How to get details about one service:

mini:~ root# launchctl list ro.gz.bs
        "StandardOutPath" = "/tmp/boot-shutdown.log";
        "LimitLoadToSessionType" = "System";
        "StandardErrorPath" = "/tmp/boot-shutdown.err";
        "Label" = "ro.gz.bs";
        "TimeOut" = 30;
        "OnDemand" = true;
        "LastExitStatus" = 0;
        "PID" = 129;
        "Program" = "/etc/boot-shutdown.sh";
        "ProgramArguments" = (

How to remove a launchd service:

osx$ sudo launchctl remove /Library/LaunchDaemons/com.plex.plexconnect.bash.plist

How to stop launchd services from command line:

osx$ sudo launchctl stop /Library/LaunchDaemons/com.plex.plexconnect.bash.plist

How to start launchd services from command line:

osx$ sudo launchctl start /Library/LaunchDaemons/com.plex.plexconnect.bash.plist

How to disable service at startup:

osx$ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.softwareupdated.plist

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.