launchctl

interface to launchd
Mac OS's master task invoker

sudo launchctl [subcommand [arguments …]]

Handles configuration and requests to load, unload daemons/agents.

keywords

Commands

procinfo pid, list, print, blame, load {-f|-s|-d}, unload,
start|stop, submit, remove, limit,
LimitLoadToHosts, LimitLoadFromHosts, LimitLoadToSessionType, EnableGlobbing,
export, getenvkey, set env

sudo launchctl list  [label]
> sudo launchctl list
(‡ is com.apple.)
PID Status  Label
-   0  ‡parentalcontrols.check 
297 0  ‡Finder
-   0  ‡PackageKit.InstallStatus
345 0  ‡iconservices.iconservicesagent
425 0  ‡ContactsAgent
-   0  ‡ManagedClientAgent.agent
-   0  ‡screensharing.agent 
…
List non apple tasks:
> launchctl list |\
  sed 1d |\
  awk ' !/0x|apple|edu\.|org\./ { print $3 } '

com.malwarebytes.HelperTool
com.openssh.sshd
com.github.IngmarStein.Monolingual.Helper
com.oracle.java.Helper-Tool
com.vix.cron
com.adobe.fpsaud  

> sudo launchctl list com.apple.syslogd
 edited 1/12/23 Ventura 13.1
{
    Program = /usr/sbin/syslogd;
    ProgramArguments = ( /usr/sbin/syslogd;);
    MachServices = { com.apple.system.logger = mach-port-object; };
    Label = com.apple.syslogd;
    OnDemand = false;
    LastExitStatus = 0; PID = 555;
    EnableTransactions = true;
    LimitLoadToSessionType = System;
};
}; 
Previouosly included:
  TimeOut=30;
  StandardOutPath  =/var/log/syslogdout;
  StandardErrorPath=/var/log/syslogderr; 
  ProgramArguments=( /usr/sbin/syslogd; -d;);
  TransactionCount=1;

  Sockets={
      AppleSystemLogger=( file-descriptor-object;);
      BSDSystemLogger  =( file-descriptor-object;);
          };

launchctl list com.apple.newsd 
{
    "EnableTransactions" = true;
    "LimitLoadToSessionType" = "Aqua";
    "MachServices" = {
        "com.apple.newsd.download" = mach-port-object;
        "com.apple.newsd.feed" = mach-port-object;
        "com.apple.newsd.today" = mach-port-object;
        "com.apple.newsd.url-resolution" = mach-port-object;
        "com.apple.newsd.analytics" = mach-port-object;
    };
    "Label" = "com.apple.newsd";
    "OnDemand" = true;
    "LastExitStatus" = 0;
    "PID" = 66410;
    "Program" = "/System/Library/PrivateFrameworks/NewsDaemon.framework/newsd";
};

print target
edited
sudo launchctl print system/com.apple.syslogd
system/com.apple.syslogd = {
    path = /System/Library/LaunchDaemons/com.apple.syslogd.plist 
                    plistbuddy /System/Library/LaunchDaemons/com.apple.syslogd.plist
                    Command: print
                    Dict {
                        Label = com.apple.syslogd
                        ProgramArguments = Array { /usr/sbin/syslogd }
                        EnablePressuredExit = false
                        EnvironmentVariables = Dict { ASL_DISABLE = 1 }
                        POSIXSpawnType = Adaptive
                        MachServices = Dict { com.apple.system.logger = true }
                        EnableTransactions = true
                        Sockets = Dict { }
                        KeepAlive = true
                        } 
    type = LaunchDaemon 
    program =     /usr/sbin/syslogd
    arguments = { /usr/sbin/syslogd }
    active count = 2
    state = running
          
    default environment = { PATH => /usr/bin:/bin:/usr/sbin:/sbin }

    environment = {
        MallocSpaceEfficient => 1
        ASL_DISABLE => 1
        XPC_SERVICE_NAME => com.apple.syslogd
    }

    domain = system
    minimum runtime = 10 base minimum runtime = 10
    exit timeout = 5
    runs = 2
    pid = 45464
    immediate reason = inefficient
    forks = 0 execs = 1 initialized = 1 trampolined = 1
    started suspended = 0
    proxy started suspended = 0
    last terminating signal = Terminated: 15

    endpoints = { "com.apple.system.logger" = { port = 0x6603 active = 1 managed = 1 reset = 0 hide = 0 watching = 0 } }

    spawn type = adaptive (6)
    jetsam priority = 140
    jetsam memory limit (active, soft) = 30 MB jetsam memory limit (inactive, soft) = 30 MB
    jetsamproperties category = daemon
    jetsam thread limit = 32
    cpumon = default
    probabilistic guard malloc policy = { activation rate = 1/1000 sample rate = 1/0 }

    properties = keepalive | supports transactions | inferred program | system service | exponential throttling
} 

( ‡ is com.apple.) services={ 0 - ‡coremedia.videodecoder 0 - ‡security.pboxd 0 - ‡LookupViewService 0 - ‡coremedia.pluginformatreader 0 - ‡appkit.xpc.openAndSavePanelService 0 - ‡audio.DriverHelper 0 - ‡foundation.UserScriptService 0 - ‡appkit.xpc.documentPopoverViewService 0 - ‡CGXPCServicesAgent 0 - ‡audio.InfoHelper 0 - ‡ColorSyncXPCAgent 0 - ‡MTLCompilerService 0 - ‡automator.xpc.workflowServiceRunner 0 - ‡appkit.xpc.VersionsUIHelper 0 - ‡DataDetectors.DataDetectorsActionService 0 - ‡audio.SandboxHelper 0 - ‡CMValidateMovieDataReferenceService 0 - ‡coremedia.videoencoder 0 - ‡audio.ComponentHelper 0 - ‡audio.ComponentTagHelper } unmanaged processes={ } endpoints={ 59803 A D ‡SpeechRecognitionCore.brokerd 1e103 A A ‡CodeSigningHelper 5910b A D ‡security.XPCTimeStampingService 59703 A D ‡iokit.IOServiceAuthorizeAgent 59403 A D ‡DictionaryServiceHelper 59307 A D ‡appkit.xpc.sandboxedServiceRunner 2290b A A ‡PerformanceAnalysis.animationperfd 1e003 A D ‡iokit.ioserviceauthorized 22103 A D ‡internal.aupbregistrarservice 64083 M D ‡MTLCompilerService 1de03 A A ‡authd 59503 A D ‡hiservices-xpcservice 59903 A D ‡accessibility.mediaaccessibilityd 59603 A D ‡security.XPCKeychainSandboxCheck } externally-hosted endpoints={ } task-special ports={ 30103 4 bootstrap ‡xpc.launchd.user.domain.501.100007.Aqua 1ac03 9 access ‡taskgated } properties={ shutting down=0 slain=0 uncorked=1 origin resolved=1 deactivated=0 inactive=0 initial on-demand=0 audit check done=0 bootcache hack=0 cocooning=0 gui=0 gui login=0 exec hack=0 } }
blame service target Displays why the service was launched.
launchctl blame gui/501/com.apple.newsd
ipc (mach)

launchctl blame  system/com.apple.syslogd 
speculative

launchctl blame  system/com.apple.auditd 
semaphore

launchctl blame  system/com.apple.hdiejectd 
(not running)

launchctl blame  system/com.apple.biomed   
event publisher

 Other reasons: 6/27/23 Ventura
   1 non-ipc demand
   2 ipc (socket)
   2 system support
   5 semaphore
   6 event publisher
   6 launch job demand
  32 xpc event
  34 speculative
  95 ipc (mach)
load
   [-F]
   [-S sessiontype]
   [-D domain]
      paths
Load configuration files (example: /System/Library/LaunchDaemons/com.apple.dpd.plist) or
directories of configuration files.
-Force the loading of the plist, i.e. Ignore Disabled

-S sessionType restrict which jobs are loaded into which session types.
      Aqua, LoginWindow, Background, StandardIO and System.

-D Look for jobs in a different location an allows

-D domain Look for plist files ending in *.plist in the domain .
   Valid domains include
system, local, network and all., user with a session type
For example, without a session type
-D system loads from property list files from : /System/Library/LaunchDaemons.
With a session type passed, it would load from : /System/Library/LaunchAgents.

sudo launchctl load /System/Library/LaunchDaemons/ftp.plist
bind(): Address already in use
com.apple.ftpd: Already loaded
-w depricated: Remove disabled from plist and write the configuration files.
unload
   [-S sessiontype]
   [-D domain]
    paths


Stop the job and
Unload configuration files or directories of configuration files.
/System/Library/LaunchDaemons > sudo launchctl unload com.apple.syslogd.plist

start Labels …
stop  Labelss …
start,
stop jobs by Label.
Jobs will restart automatically if demand driven. i.e. KeepALive,watchPaths,QueueDirectories, StartOnMount,StartInterval ,Sockets or StartCalendarInterval
submit  -l label
[-p executable]
[-o path.out]
[-e path.err]
-- command [args]
submit a program to run without a configuration file.
launchd will keep the program alive in the event of failure.
-o path.out stdout
-e path.err stderr
remove label from launchd
limit resource
[soft hard]]
[both |
With no arguments, displays all the resource limits via getrlimit(2).
resource      soft          hard      
cpu         unlimited      unlimited      
filesize    unlimited      unlimited      
data        unlimited      unlimited      
stack       8388608        67104768       
core              0        unlimited      
rss         unlimited      unlimited      
memlock     unlimited      unlimited      
maxproc     266            532            
maxfiles    256            unlimited      

sudo launchctl limit core 500000 2000000    # set reasonable limits
                                            # i.e. not unlimited!  
limit resource , displays the limits for that resource.
limit resource hhss , sets both the hard and soft limits to same value.
limit resource hh ss sets        the hard and soft limits.
LimitLoadToHosts,
LimitLoadFromHosts,
LimitLoadToSessionType
This configuration file only applies to the hosts listed with this key.
Set kern.host-name kern.hostname name in for this feature to work reliably.
LimitLoadToSessionType see -S
EnableGlobbinguse the glob(3) mechanism to update the program arguments before invocation.
shutdown 
umask [newmask] Get or set the umask(2) of launchd. default 022 (i.e. files are created 755 rwxr-xr-x )
[un]setenv key value [un]Set an environmental variable inside of launchd.
getenv key Get an environmental variable inside of launchd.
export Export environmental variables of launchd for use in a shell eval statement.
launchctl export
PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;
getrusage
   self | children
Get the resource utilization statistics for launchd or the children of launchd.

Sample

launchctl getrusage self
0.308193   user time used
3.970984   system time used
0          max resident set size
0          shared text memory size
0          unshared data size
0          unshared stack size
0          page reclaims
0          page faults
0          swaps
 30        block input operations
  3        block output operations
353        messages sent
249        messages received
  0        signals received
621        voluntary context switches
  0        involuntary context switches
launchctl getrusage children
 220.193474   user time used
 126.145974   system time used
 68022272     max resident set size
 0            shared text memory size
 0            unshared data size
 0            unshared stack size
 1447425      page reclaims
 33518        page faults
 0            swaps
 26113        block input operations
 18913        block output operations
 81014        messages sent
 8076         messages received
 217          signals received
 63150        voluntary context switches
 900358       involuntary context switches
bslist List Mach bootstrap services and optional servers

active (A), inactive (I) and on-demand (D).

prefix is com.apple

D .launchd.peruser.4294967294
A .launchd.peruser.501
D .CoreRAID
D .launchd.peruser.65
A .windowserver.active
A .windowserver
D .webfilter
D .UNCUserNotification
D .taskgated
A .system.logger
D .spinreporterd
D .smbfs_load_kext
D .service_helper
A .SecurityServer
D .seatbelt.compilerd
D .iokit.scsid
D .ReportCrash.SafetyNet
D .ReportCrash
D .ReportCrash.DirectoryService
A .RemoteDesktop.PrivilegeProxy
D .ocspd
A .system.notification_center
D .netauth.sysagent
D .mio.VDCAssistant
D .mio.IIDCVideoAssistant
A .metadata.mds
D .mDNSResponderHelper
A .mDNSResponder
A .UNCUserNotification.session.256
A .O3Master
D .lockd
D .system.Kernel[UNC]Notifications
A .KernelExtensionServer
D .KerberosAutoConfig
D .java.updateSharingD
D .installdb.system
D .IIDCAssistant
A .iohideventsystem
D .system.hdiejectd
D .gssd
A .FSEvents
D .familycontrols
D .dyld
A .distributed_notifications.2
A .DiskArbitration.diskarbitrationd
D .DirectoryService.localonly
A DirectoryService::CPluginRunLoopThread.14
A .DirectoryService
A .system.DirectoryService.libinfo_v1
A .CoreServices.coreservicesd
A .network.IPConfiguration
A .network.EAPOLController
A .SystemConfiguration.PPPController
A .PowerManagement.control
A .SystemConfiguration.configd
D .bsd.dirhelper
D .BluetoothNILServer
D .backupd
D .automountd
A .audio.coreaudiod
D .FontObjectsServer
A .alf
D .airport.updateprefs
D .airportd
D .airport.wps
D .dashboard.advisoryd
D .mio.AVCAssistant

bootstrap
bootout launchctl bootout domain-target [service-path1, service-path2, …]| service-target
singleuserHappens instantly without confirmation!
bsexec Execute a process within a different Mach bootstrap subset
help
As of Elcaptian 10.11.6

launchctl subcommand| help [subcommand]

Many subcommands take a target specifier that refers to a domain or service within that domain.
The available specifier forms are:
system/[service-name]

user/uid>/[service-name]
Targets the user domain or service within.
A process running as the target user may make modifications.

gui/uid/[service-name] Each GUI domain is associated with a user domain,

session/<asid>/[service-name]

pid/pid/[service-name]

Only the process which owns the domain may modify it. Even root may not do so.

When using a legacy subcommand which manipulates a domain, the target domain is inferred from the current execution context.
When run as root (whether it is via a root shell or sudo(1)), the target domain is assumed to be the system-wide domain.
When run from a normal user's shell, the target is assumed to be the per-user domain for that current user.

Subcommands:

bootstrap service Bootstraps a domain or a service into a domain.
bootout service Tears down a domain or removes a service from a domain.
sudo launchctl bootout gui/501/com.apple.newsd
Boot-out failed: 150: Operation not permitted while System Integrity Protection is engaged
enable service Enables an existing service.
sudo /bin/launchctl enable "system/com.apple.locate"
disable service
launchctl disable gui/501/com.apple.newsd
kickstart service Forces an existing service to start.
attach service Attach the system's debugger to a service.
debug service Configures the next invocation of a service for debugging.
sudo launchctl debug gui/$UID/service-target --stdout --stderr
On another terminal : launchctl start service-target
kill sig Sends a signal to the service .
ps -eal |g newsd
  501  6862 93907     4006   0  
sudo killall -signal kill newsd
% launchctl list com.apple.newsd
{
    "EnableTransactions" = true;
    "LimitLoadToSessionType" = "Aqua";
    "MachServices" = {
        "com.apple.newsd.download" = mach-port-object;
        "com.apple.newsd.feed" = mach-port-object;
        "com.apple.newsd.today" = mach-port-object;
        "com.apple.newsd.url-resolution" = mach-port-object;
        "com.apple.newsd.analytics" = mach-port-object;
    };
    "Label" = "com.apple.newsd";
    "OnDemand" = true;
    "LastExitStatus" = 9;
    "Program" = "/System/Library/PrivateFrameworks/NewsDaemon.framework/newsd";
};
blame service Outputs the reason a service is running.
> sudo launchctl blame system/com.apple.syslogd
speculative 

(not running)

> sudo launchctl blame system/com.apple.Spotlight
Could not find service "com.apple.Spotlight" in domain for system
rc:113

> sudo launchctl blame gui/501/com.apple.Spotlight
ipc (mach)

print Outputs a description of a domain or service.
print-cache example:
      "/System/Library/LaunchAgents/com.apple.controlcenter.plist" = {
            "EnableTransactions" = false;
            "ProcessType" = "App";
            "ThrottleInterval" = 1;
            "EnablePressuredExit" = false;
            "MachServices" = { "com.apple.controlcenter" = { }; }; 
            "LimitLoadToSessionType" = ( "Aqua";);
            "Label" = "com.apple.controlcenter";
            "KeepAlive" = { "SuccessfulExit" = false; };
            "POSIXSpawnType" = "App";
            "Program" = "/System/Library/CoreServices/ControlCenter.app/Contents/MacOS/ControlCenter";
        };
print-disabled As of 6/06/22 Monterey 12.4
launchctl print-disabled system |grep true  
    "com.apple.CSCSupportd" => true
    "com.apple.ftpd" => true
    "com.apple.mdmclient.daemon.runatboot" => true
plist Outputs a property list embedded in a binary (targets the Info.plist by default).
procinfo
hostinfo
resolveport Resolves a port name from a process to an endpoint in launchd.
limit Reads or modifies launchd's limits.
WARNING: since launchd runs the system modifying launchd's limits probably should not be done.!
[limit-name {<both-limits> | <soft-limit> | <hard-limit>}
{cpu | filesize | data | stack | core | rss | memlock | maxproc | maxfiles}
> sudo launchctl limit cpu
    cpu         unlimited      unlimited      
    filesize    unlimited      unlimited      
    data        unlimited      unlimited      
    stack       8388608        67104768       
    core        0              unlimited      
    rss         unlimited      unlimited      
    memlock     unlimited      unlimited      
    maxproc     2784           4176           
    maxfiles    256            unlimited    
runstats Outputs performance statistics for a service.
Performance logging is not enabled.
rc:45
examine Runs analysis tool against launchd in a non-reentrant manner.
config Modifies persistent configuration parameters for launchd domains.
dumpstate Dumps launchd state to stdout.(big)
reboot system
bootshell from single-user mode with a console shell.
load Bootstraps a service or directory of services.
unload Unloads a service or directory of services.

To restart a process after changing it or its configuration:
 sudo launchctl unload /System/Library/LaunchDaemons/com.apple.name.plist && \
 sudo launchctl load   /System/Library/LaunchDaemons/com.apple.name.plist &&\
 launchctl list com.apple.name
remove service Unloads name.
list [service] Lists information about services.
Without service lists all ( 450+ ) services.
sudo launchctl list com.apple.analyticsd
   "EnableTransactions" = true;
    "LimitLoadToSessionType" = "System";
    "MachServices" = {
        "com.apple.analyticsd.messagetracer" = mach-port-object;
        "com.apple.analyticsd" = mach-port-object;
    };
    "Label" = "com.apple.analyticsd";
    "OnDemand" = true;
    "LastExitStatus" = 0;
    "PID" = 620;
    "Program" = "/System/Library/PrivateFrameworks/CoreAnalytics.framework/Support/analyticsd";
    "ProgramArguments" = (
        "/System/Library/PrivateFrameworks/CoreAnalytics.framework/Support/analyticsd";
    );
};

start service Starts .
stop service Stops if it is running.

setenv Sets environment variables for all services within the domain.
unsetenv Unsets environment variables for all services within the domain.
getenv Gets the value of an environment variable from within launchd.
bsexec Execute a program in another process' bootstrap context.
asuser Execute a program in the bootstrap context of a given user.
submit Submit a basic job from the command line.
managerpid 1 PID of the launchd controlling the session.
manageruid 501 UID of the current launchd session.
managername Aqua name of the current launchd session.
error description of an error.
variant RELEASE
version
Darwin Bootstrapper Version 3.4.0: Sat Apr  2 20:54:16 PDT 2016; 
                            root:TempContent/launchd/RELEASE_X86_64
help Outputs the usage for a given subcommand.

Usage

First
launchctl list |grep -i mozy
then                                   output edited to reduce display size and avoid line wrap
launchctl list "[0x0-0x10010].com.mozy.status"
{ "Label"="[0x0-0x10010].com.mozy.status";
  "LimitLoadToSessionType"="Aqua"; "OnDemand"=true; "LastExitStatus"=0; "TimeOut"=30;
  "PID"=180;
  "ProgramArguments"=(
  "/Applications/MozyHome.app/Contents/Resources/MozyHome Status.app/Contents/MacOS/MozyHome Status";
                "-psn_0_65552";
                       );
  "MachServices"={ };
  "PerJobMachServices"={
     "com.apple.CFPasteboardClient"=mach-port-object;
     "com.apple.coredrag"=mach-port-object;          "com.apple.tsm.portname"=mach-port-object;
     "com.apple.axserver"=mach-port-object;          "WakeUpProcessPort"     =mach-port-object; };
};
list      ( ‡ is com.apple)
 PID Status  Label
1360 - 0x10b520.launchctl
1340 - 0x10b420.ssh
1330 - 0x10b320.bash
1329 - 0x1091c0.login
1281 - [0-0x2c02c].‡AppleSpell
 972 - 0x10ab40.Backup
 317 - [0-0x18018].org.mozilla.firefox
 166 - 0x109fd0.bash
 165 - 0x109e40.login
 164 - [0-0x15015].‡Terminal
 161 - [0-0x14014].‡Safari
 159 - [0-0x13013].‡Console
 141 - [0-0x10010].‡speech.synthesis.
              SpeechSynthesisServer
     - 0 0x108770.rcd
 131 - [0-0xd00d].‡finder
 130 - [0-0xc00c].‡systemuiserver
 126 - [0-0xb00b].‡dock
     - 0 0x1071b0.BezelUIServer
     - 0 org.x.X11
 251 -   org.openbsd.ssh-agent
     - 0 edu.mit.Kerberos.KerberosAgent
     - 0 ‡CoreMIDIServer
 121 -   ‡UserEventAgent-Aqua
     - 0 ‡syncservices.uihandler
     - 0 ‡syncservices.SyncServer
 120 -   ‡Spotlight
     - 0 ‡ServerScanner
     - 0 ‡scrod
 118 -   ‡ScreenSharing.server
     - 0 ‡ReportPanic
     - 0 ‡ReportCrash.SafetyNet
     - 0 ‡ReportCrash
     - 0 ‡RemoteUI
     - 0 ‡RemoteDesktop.agent
     - 0 ‡quicklook
     - 0 ‡qtkitserver
     - 0 ‡PubSub.Agent
     - 0 ‡ProblemReporter
     - 0 ‡PreferenceSyncAgent
     - 0 ‡pictd
     - 0 ‡PCIESlotCheck
     - 0 ‡pbs
122  -   ‡pboard
     - 0 ‡NetworkDiagnostics
     - 0 ‡netauth.useragent
     - 0 ‡metadata.mdwrite.plist
     - 0 ‡java.updateSharingD_debug
     - 0 ‡installdb.user
     - 0 ‡imklaunchagent
     - 0 ‡helpdata
     - 0 ‡ATS.FontValidatorConduit
     - 0 ‡ATS.FontValidator
     
134  -   ‡FileSyncAgent
     - 0 ‡familycontrols.useragent
     - 0 ‡dotmacsync.uihandler
     - 0 ‡dotmac.notification
     - 0 ‡DictionaryPanelAgent
     - 0 ‡coreservices.uiagent
127  -   ‡ATSServer
     - 0 ‡alf.useragent
115  -   ‡AirPortBaseStationAgent
     - 0 ‡AddressBook.abd
114  -   ‡FolderActions.enabled
39   - 102AB0.loginwindow   ---.       
83   - 0x102940.WindowServer    |   
24   - 0x1025c0.securityd       |   
     - 0 ‡launchctl.Aqua        |   
166  - 0x10b220.bash            |
165  - 0x10b120.login           |
164  - 0x10b020.Terminal        |notice 
110  - 0x10af20.launchd         |multiple
     - 0 ‡FolderActions.folders |
76   - 0x1073c0.coreservicesd   |  
39   - 100DC0.loginwindow   ---'
     - 0 edu.mit.Kerberos.CCacheServer
     - 0 ‡seatbelt.compiler
     - 0 ‡KerberosHelper.LKDCHelper
     - 0 ‡gssd-agent
     - 0 ‡launchctl.Background 
PS on same system
 PID  PPID COMMAND           PID  PPID COMMAND 
 1   0 /sbin/launchd
13  1 /usr/libexec/kextd          14  1 /usr/sbin/DirectoryService
15  1 /usr/sbin/notifyd          16  1 /usr/sbin/syslogd
17  1 /usr/sbin/configd          18  1 /usr/sbin/distnoted
19  1 /usr/sbin/mDNSResponder -launchd
24  1 /usr/sbin/securityd -i
28  1 /usr/sbin/ntpd -n -g -p /var/run/ntpd.pid -f /var/db/ntp.drift
29  1 /usr/sbin/cupsd -l
31  1 /usr/sbin/cron             32   1 /usr/sbin/update
33  1 /sbin/SystemStarter
37  1 /System/Library/CoreServices/RemoteManagement/AppleVNCServer.bundle/Contents/Support/RFBRegisterMDNS
38  1 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Support/mds
39  1 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
40  1 /usr/sbin/KernelEventAgent
41  1 /usr/sbin/kdcmond -n -a
43  1 /usr/libexec/hidd
44  1 /System/Library/Frameworks/CoreServices.framework/
               Versions/A/Frameworks/CarbonCore.framework/Versions/A/Support/fseventsd
46  1 /sbin/dynamic_pager -F /private/var/vm/swapfile
48  1 /usr/sbin/diskarbitrationd
52  1 autofsd
53  1 /usr/libexec/ApplicationFirewall/socketfilterfw
76  1 /System/Library/CoreServices/coreservicesd
83  1 /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/WindowServer -daemon
     …

ENVIRONMENTAL VARIABLES

LAUNCHD_SOCKET which launchd should use to talk to

FILES

all have suffix .plist
Per-user agents.
/System/Library/LaunchAgents
System wide daemons.
/System/Library/LaunchDaemons
gCoreMIDIServer
‡ATSServer   
‡AddressBook.abd
‡AirPortBaseStationAgent
‡DictionaryPanelAgent
‡FileSyncAgent
‡FontValidator
‡FontValidatorConduit
‡KerberosHelper.LKDCHelper
‡NetworkDiagnostics
‡PCIESlotCheck
‡PreferenceSyncAgent
‡ProblemReporter
‡PubSub.Agent
‡RemoteDesktop
‡RemoteUI
‡ReportCrash.SafetyNet
‡ReportCrash
‡ReportPanic
‡ScreenSharing
‡ServerScanner
‡Spotlight
‡UserEventAgent-Aqua
‡UserEventAgent-LoginWindow
‡alf.useragent
‡coreservices.uiagent
‡dotmac.dmnotifyd
‡dotmacsync.uihandler
‡familycontrols.useragent
‡gssd-agent
‡helpdata
‡imklaunchagent
‡installdb.user
‡java.updateSharingD_debug
‡metadata.mdwrite
‡netauth.useragent
‡pboard
‡pbs
‡pictd
‡qtkitserver
‡quicklook
‡scrod
‡seatbelt.compiler
‡syncservices.SyncServer
‡syncservices.uihandler
edu.mit.Kerberos.CCacheServer
edu.mit.Kerberos.KerberosAgent
org.openbsd.ssh-agent
org.x.X11

Daemons with ¬ are Disabled
bootps¬
‡ATSServer
‡AppleFileServera¬
‡CoreRAID
‡DirectoryServices
‡DirectoryServicesLocal
‡DumpPanic
‡FileSyncAgent.sshd¬
‡IFCStart
‡IIDCAssistant
‡InternetSharing¬
‡KerberosAutoConfig
‡KernelEventAgent
‡ODSAgent¬
‡PasswordService¬
‡RFBRegisterMDNS_RemoteManagement
‡RFBRegisterMDNS_ScreenSharing
‡RemoteDesktop.PrivilegeProxy
‡ReportCrash.DirectoryService
‡ReportCrash.SafetyNet
‡ReportCrash
‡ServerPerfLog
‡SystemStarter
‡UserNotificationCenter
‡WindowServer
‡airport.wps
‡airportPrefsUpdater
‡airportd
‡alf.agent
‡atrun¬
‡audio.coreaudiod
‡autofsd
‡automountd
‡backupd-attach
‡backupd-auto¬
‡backupd
‡blued
‡bootlog
‡bsd.dirhelper
‡comsat¬
‡configd
‡configureLocalKDC
‡coreservicesd
‡dashboard.advisory.fetch
‡diskarbitrationd
‡distnoted
‡dnsextd¬
‡docsetinstalld¬
‡dyld
‡dynamic_pager
‡efax¬
‡emlog¬
‡emond
‡eppc¬
‡familycontrols
‡firmwaresyncd
‡fseventsd
‡ftp-proxy¬
‡getty¬
‡gssd
‡hdiejectd
‡hidd
‡installdb.system
‡java.updateSharingD
‡kdcmond
‡kdumpd¬
‡kextd
‡kuncd
‡locate¬
‡lockd
‡loginwindow
‡mDNSResponder
‡mDNSResponderHelper
‡metadata.mds
‡mio.AVCAssistant
‡mio.IIDCVideoAssistant
‡mio.VDCAssistant
‡msrpc.echosvc¬
‡mtmd¬
‡mtmfs¬
‡netbiosd
‡netauth.sysagent
‡newsyslog
‡nfsd
‡nis.rpc.yppasswdd
‡nis.ypbind
‡nis.ypserv
‡notifyd
‡ocspd
‡odproxyd¬
‡pcastagentd
‡periodic-daily
‡periodic-daily.plist~
‡periodic-monthly
‡periodic-weekly
‡pfctl
‡portmap
‡postgres¬
‡printtool.daemon
‡scsid
‡screensharing¬
‡seatbelt.compilerd
‡securityd
‡security.FDERecoveryAgent¬
‡security.syspolicy
‡service_helper
‡smb.server.preferences
‡smbd
‡smbfs_load_kext
‡spindump
‡stackshot
‡statd.notify
‡syslogd
‡systemkeychain
‡taskgated
‡update
‡usbmuxd
‡ucupdate
‡uucp¬
‡webfilter
‡xgridagentd
‡xgridcontrollerd
‡xsan¬
‡xsanmgrd¬
‡xscertadmin¬
‡xscertd-helper¬
‡xscertd¬
com.vix.cron
exec¬
finger ¬
ftp¬
login¬
ntalk¬
org.amavis.amavisd
org.apache.httpd¬
com.danga.memcached¬
org.cups.cups-lpd¬
org.cups.cupsd
org.isc.named
org.net-snmp.snmpd¬
org.openldap.slapd¬
org.ntp.ntpd
org.postfix.master
org.samba.winbindd
shell¬
ssh¬
telnet¬
tftp¬

/Library/LaunchAgents Per-user agents provided by the administrator.
com.google.keystone.agent.plist   update agent! defaults
com.oracle.java.Java-Updater.plist
org.macosforge.xquartz.startx.plist

~/Library/LaunchAgents Per-user agents provided by the user.
See System preferences/general/login items<.code>.
empty smacker 3/17/08
/Library/LaunchDaemons System wide daemons provided by the administrator
Causes icon to appear in menubar(?)
com.adobe.fpsaud.plist
com.ea.origin.ESHelper.plist
com.fitbit.galileod.plist
com.google.keystone.daemon.plist
com.oracle.java.Helper-Tool.plist
com.oracle.java.JavaUpdateHelper.plist
org.macosforge.xquartz.privileged_startx.plist

com.sophos.intercheck.plist
com.sophos.notification.plist
com.sophos.autoupdate.plist
com.mozy.backup.plist
 <key>Label</key> <string>com.mozy.backup</string>
 <key>OnDemand</key> <false/>
 <key>RunAtLoad</key> <true/>
 <key>ProgramArguments</key> 
    <array> 
      <string>/Applications/MozyHome.app/Contents/Resources/MozyHomeBackup</string> 
   </array>
 <key>ServiceIPC</key> <false/>
 <key>UserName</key> <string>root</string>
 <key>GroupName</key> <string>wheel</string>
        
Library/SyncedPreferences > lt
  1034 Sep 17  2015 com.apple.mail-com.apple.mail.vipsenders.plist
  3219 Jan 10  2016 icbaccountsd.plist
    87 Jan 25  2016 com.apple.Safari-com.apple.Safari.UserRequests.plist
   786 Mar  5 17:36 com.apple.finder.plist
   663 Mar 12 20:29 com.apple.ncplugin.weather.plist
  1428 Apr  4 20:31 com.apple.ncplugin.stocks.plist
   553 May 28 21:12 com.apple.Safari-com.apple.Safari.WebFeedSubscriptions.plist
  1122 May 30 12:01 com.apple.cmfsyncagent.plist
  7229 Jul 27 08:07 com.apple.CoreSuggestions.plist
  7353 Jul 27 08:07 suggestd.plist
   483 Jul 27 12:42 com.apple.sbd.plist
  3085 Jul 27 14:38 accountsd.plist
 30409 Jul 29 19:31 com.apple.wifi.WiFiKeychainProxy.plist
 27585 Jul 29 19:31 com.apple.wifi.WiFiAgent.plist
 93344 Jul 29 19:31 com.apple.security.cloudkeychainproxy3.plist
  4043        15:53 com.apple.Safari.plist
 15260        15:53 com.apple.syncedpreferences.plist
  4340        15:53 com.apple.SafariServices.plist
/Library/StartupItems
MySQLCOM (oops not invoked 3/21/16)
comapcpcpestart Compac PowerChute
nipal (not invoked 3/21/16)

See

launchd.plist, launchd.conf(5), launchd(8)
No longer present

/System/Library/LaunchDaemons/bootpd.plist

 <key>Disabled</key> <true/>
    <key>Label</key> <string>com.apple.bootpd</string>
    <key>ProgramArguments</key> <array> <string>/usr/libexec/bootpd</string> </array>
    <key>inetdCompatibility</key> <dict> <key>Wait</key> <true/> </dict>
    <key>Sockets</key> <dict> <key>Listeners</key> <dict>
            <key>SockServiceName</key> <string>bootps</string>
            <key>SockType</key>        <string>dgram</string>
            <key>SockFamily</key>      <string>IPv4</string>

/System/Library/LaunchDaemons/com.apple.locate.plist

/System/Library/LaunchDaemons/com.apple.bootlog
<key>ProgramArguments</key> <array> <string>/usr/libexec/bootlog</string> </array>
    <key>RunAtLoad</key>      <true/>
    <key>LaunchOnlyOnce</key> <true/>

Now binary plist > cat /System/Library/LaunchDaemons/telnet.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <true/> <key>Label</key> <string>com.apple.telnetd</string> <key>ProgramArguments</key> <array> <string>/usr/libexec/telnetd</string> </array> <key>inetdCompatibility</key> <dict> <key>Wait</key> <false/> </dict> <key>Sockets</key> <dict> <key>Listeners</key> <dict> <key>SockServiceName</key> <string>telnet</string> <key>Bonjour</key> <true/> </dict> </dict> <key>SessionCreate</key> <true/> </dict> </plist>


telnet smacker
Trying 192.168.1.9…
telnet: connect to address 192.168.1.9: Connection refused

sudo launchctl load -F /System/Library/LaunchDaemons/telnet.plist   (-F force as plist says disabled)

telnet smacker
Trying 192.168.1.9…
Connected to smacker.GERMANS.
Escape character is '^]'.
login: 

sudo launchctl stop  com.apple.telnetd

<key>Label</key> <string>com.vix.cron</string> <key>ProgramArguments</key> <array> <string>/usr/sbin/cron</string> </array> <key>KeepAlive</key> <dict> <key>PathState</key> <dict> <key>/etc/crontab </key> <true/> </dict> </dict> <key>QueueDirectories</key> <array> <string>/usr/lib/cron/tabs</string> </array>
Darwin September 30, 2004

Double Clicking on a plist in finder starts Property List Editor, See PlistBuddy

There exists lingon which is a little more sexy by Peter Borg .

There is alsp pl which converts xml to keyword=value format (VERY NiCE!) pl -input fi_xml.plisti -Output fi.txt


GETRLIMIT(2) BSD System Call

getrlimit, setrlimit -- control maximum system resource consumption

     #include  
     int getrlimit(int resource, struct rlimit *rlp); 
     int setrlimit(int resource, const struct rlimit *rlp);
Limits on the consumption of system resources by the current process and each process it creates may be obtained with the getrlimit() call, and set with the setrlimit() call.

resource Maximums
RLIMIT_CPU cpu seconds
RLIMIT_NOFILE number of open files
RLIMIT_FSIZE bytes of files that may be created.
RLIMIT_NPROC number of simultaneous processes
RLIMIT_MEMLOCK memory using mlock(2)
RLIMIT_RSS resident set size, i.e. physical memory
RLIMIT_DATA data segment ; how far a program may extend its break with the sbrk(2) system call.
RLIMIT_STACK stack segment
RLIMIT_CORE size of core file that may be created.

A resource limit is specified as a soft limit and a hard limit.
When a soft limit is exceeded a process may receive a signal (for example, if the cpu time or file size is exceeded), but it will be allowed to continue execution until it reaches the hard limit (or modifies its resource limit).

 
           struct rlimit { rlim_t  rlim_cur;       /* current (soft) limit */
                           rlim_t  rlim_max;       /* hard limit */ };
Processes may alter rlim_cur (Soft) within the range from 0 to rlim_max (Hard) or
(irreversibly) lower rlim_max. Only the super-user may raise the maximum limits.

This is a per-process limit, and affects all child processes
A break call fails if the data space limit is reached.
When the stack limit is reached, the process receives a segmentation fault (SIGSEGV).

A file I/O operation that would create a file larger that the process' soft limit will cause the write to fail and SIGXFSZ to be generated; .
When the soft cpu time limit is exceeded, SIGXCPU is sent .

Return Values

  0 success
-1 error code is stored in the global location errno.

Errors

getrlimit() and setrlimit() system calls will fail if:
[EFAULT] address for rlp is invalid.
[EINVAL] resource is invalid.

The setrlimit() call will fail if:
[EINVAL] limit is invalid (e.g., RLIM_INFINITY or lower than rlim_cur).
[EPERM] limit specified would have raised the maximum limit value and the caller is not the super-user.

Legacy Synopsis

     #include <sys/types.h>
   #include <sys/time.h>
   #include <sys/resource.h>

As of Sierra no longer runs interactively

As of Yosemite /System/Library/LaunchDaemons/com.apple.SystemStarter.plist no longer includes the invocation of

The include files <sys/types.h> and <sys/time.h> are necessary.

Compatibility

setrlimit() now returns with errno set to EINVAL in places that historically succeeded.
It no longer accepts "rlim_cur=RLIM_INFINITY" for RLIM_NOFILE.
Use "rlim_cur=min(OPEN_MAX, rlim_max)".

These commands can be stored in $HOME/.launchd.conf or /etc/launchd.conf to be read at the time launchd starts.(seems to be no longer used as per Mavericks)

See

csh(1), sh(1), quota(2), sigaction(2), sigaltstack(2), sysctl(3), compat(5)

How does apache get started on OS X?

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist


How does mysqld get started on OS X?

  1. Get process id:
  2. interesting non-standard (?) items

    Launchd includes explicit calls to rc.server

            com.apple.xpc.launchd.ioq, throttle-queue,  bgioq
    sudo launchctl list | sed 1d | awk '!/0x|com\.(apple|openssh|vix)|org\.(amav|apac|cups|isc|ntp|postf|x)/{print $3}'
    
    com.sophos.scan    (anti vrus)
    com.sophos.intercheck
    com.sophos.autoupdate
    com.sophos.notification
    com.sophos.configuration
    com.sophos.common.servicemanager
    com.cirtx
    
    
    com.adobe.fpsaud 
    com.ea.origin.ESHelper
    com.fitbit.galileod   
    com.google.keystone.daemon
    org.macosforge.xquartz.privileged_startx
    com.oracle.java.JavaUpdateHelper
    com.oracle.java.Helper-Tool
    org.wireshark.ChmodBPF
    com.citrixonline.GoToMeeting.G2MUpdate.plist 
    
    
    ~/Library/LaunchAgents/com.citrixonline.GoToMeeting.G2MUpdate.plist 
    ~/Library/Application Support/CitrixOnline/GoToMeeting/G2MUpdate
    vi /Library/LaunchDaemons/com.kaspersky.safekids.plist
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      list version="1.0">
    <dict>
        <key>Label</key> <string>com.kaspersky.safekids</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Library/Application Support/Kaspersky Lab/SafeKids/Binaries/safekids</string> <string>-r</string> <string>-bl</string>
        </array>
        <key>RunAtLoad</key> <true/>
        <key>ServiceIPC</key> <false/>
        <key>StandardErrorPath</key> <string>/var/log/safekids_daemon_stderr.log</string>
        <key>StandardOutPath</key> <string>/var/log/safekids_daemon_stdout.log</string>
        <key>KeepAlive</key> <dict> <key>SuccessfulExit</key> <false/> </dict>
        <key>WatchPaths</key> <array> <string>/Library/Application Support/Kaspersky Lab/SafeKids/kickstart</string> </array>
    </dict>
    </plist>
    
    
    

    Following /System/Library/LaunchDaemon/com.apple… plists
    include StartCalendarInterval as of 7/17/21 Monterey

    bsd.dirhelper:     Hour 3 Minute 35
    csrutil.report:    Hour 3 Minute 20 
    emond.aslmanager:  Hour 3 Minute 25
    gkreport:          Hour 3 Minute 52 WeekDay 5
    locate:            Hour 3 Minute 15
    logkextloadsd:     Hour 14          Weekday 2 
    newsyslog:                Minute 30
    systemstats.daily: Hour 0 Minute 15 
    Since Launchd StartCalendarInterval starts tasks missed while system is sleeping/not running,
    most of the above will be run (annoyingly) on next awakining(I think)

    There is no root crontab in Mac OS, rather /System/Library/LaunchDaemons files sometimes include:

      <key>StartCalendarInterval</key>
        <dict>
            <key>Day</key> <integer>11</integer>
            <key>Hour</key> <integer>0</integer>
            <key>Minute</key> <integer>0</integer>
            <key>Month</key> <integer>7</integer>
            <key>Weekday</key> <integer>0</integer>
        </dict> 
    
    bootout and disable