launchctl

interface to launchd
Mac OS's master task invoker

launchctl [subcommand [arguments …]]

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

As of Sierra no longer runs interactively


There is no root crontab in Mac OS X, 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>

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

keywords

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)

list  [Label]
 >launchctl list
PID Status  Label
15117   0   ‡quicklook
-   0   ‡parentalcontrols.check
297 0   ‡Finder
-   0   ‡PackageKit.InstallStatus
435 0   ‡mediaremoteagent
-   0   ‡FontWorker
303 0   ‡bird
-   0   ‡familycontrols.useragent
-   0   ‡universalaccessAuthWarn
389 0   ‡nsurlsessiond
-   0   ‡syncservices.uihandler
345 0   ‡iconservices.iconservicesagent
425 0   ‡ContactsAgent
-   0   ‡ManagedClientAgent.agent
-   0   ‡screensharing.agent




sudo launchctl list com.apple.dpd
{ "Label"="com.apple.dpd";
  "LimitLoadToSessionType"="System";
  "OnDemand"=true;
  "LastExitStatus"=0;
  "TimeOut"=30;
  "StandardErrorPath"="/var/log/dpd.log";
  "ProgramArguments"=( "/usr/libexec/dpd";);
  "MachServices"={ "com.apple.dpd"=mach-port-object; };
}; 
multiple lines joined for your viewing pleasure
/System/Library/LaunchDaemons > sudo launchctl list com.apple.syslogd
{ "Label"="com.apple.syslogd";
  "LimitLoadToSessionType"="System";
  "OnDemand"=false;
  "LastExitStatus"=0;
  "PID"=28818;
  "TimeOut"=30;
  "StandardOutPath"="/var/log/syslogdout";
  "StandardErrorPath"="/var/log/syslogderr";
  "ProgramArguments"=( "/usr/sbin/syslogd"; "-d";);
  "EnableTransactions"=true;
  "TransactionCount"=1;
  "Sockets"={
      "AppleSystemLogger"=( file-descriptor-object;);
      "BSDSystemLogger"=( file-descriptor-object;);
  };
  "MachServices"={ "com.apple.system.logger"=mach-port-object; };
};
print target
 >sudo launchctl print pid/374  rearranged
com.apple.xpc.launchd.domain.pid.AirPlayUIAgent.374={
    type=process
    handle=374
    active count=21 on-demand count=1 service count=20 active service count=0
    activity ratio=0.00
    originator=/System/Library/CoreServices/AirPlayUIAgent.app/Contents/MacOS/AirPlayUIAgent
    creator=AirPlayUIAgent.374
    creator euid=501
    uniqueid=374
    external activation count=0
    security context={ uid=501 asid=100007 }

    bringup time=1 ms death port=0x6431b

    in-progress bootstraps=0
    pended requests=0 pending requests={ }
    subdomains={ }
    pending attachments={ }

    environment={
        PATH => /usr/bin:/bin:/usr/sbin:/sbin
        SSH_AUTH_SOCK => /private/tmp/com.apple.launchd.If5jThnS3R/Listeners
        Apple_PubSub_Socket_Render => /private/tmp/com.apple.launchd.6Ijf4scZCj/Render
        HOME => /Volumes/DATA/dgerman
        TMPDIR => /var/folders/03/jm885yvs39qdz6p_3r6bvhnh0000gn/T/
    }

( ‡ 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
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 given.
   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
launchd% 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 if it is running and
Unload the specified configuration files or directories of configuration files.
/System/Library/LaunchDaemons > sudo launchctl unload com.apple.syslogd.plist

Disables are (as of 10.6.x) stored in
/private/var/db/launchd/com.apple.xpc.launchd/disabled.plist
as entries like:

 <key>com.apple.AppleFileServer</key>
<dict>
    <key>Disabled</key> <true/>
</dict>

start Labels …
stop  Labelss …
start,
stop the specified 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]
[-e path]
-- command [args]
submit a program to run without a configuration file.
launchd will keep the program alive in the event of failure.
-p program
-o path to send program's stdout
-e path to send program's stderr
remove label from launchd
log [level loglevel]
 [
only | mask loglevels..]
Get and set the syslog(3) log level mask.
debug, info, notice, warning, error, critical, alert and emergency.
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      
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.
launchd% 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

launchd% 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
launchd% 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
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       Bootstraps a domain or a service into a domain.
    bootout         Tears down a domain or removes a service from a domain.
    enable          Enables an existing service.
    disable         
    uncache         Removes the specified service name from the service cache.
    kickstart       Forces an existing service to start.
    attach          Attach the system's debugger to a service.
    debug           Configures the next invocation of a service for debugging.
    kill            Sends a signal to the service instance.

    blame           outputs the reason a service is running.
    print           outputs a description of a domain or service.
    print-cache     
    print-disabled  
    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 resource limits.
    runstats        outputs performance statistics for a service.
    examine         Runs the specified 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.
    remove          Unloads the specified service name.
    list            Lists information about services.
    start           Starts the specified service.
    stop            Stops the specified service if it is running.
    setenv          Sets the specified environment variables for all services within the domain.
    unsetenv        Unsets the specified 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

Per-user agents.
/System/Library/LaunchAgents
System wide daemons.
/System/Library/LaunchDaemons
gCoreMIDIServer
†ATSServer   all have suffix .plist
†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
com.oracle.java.Java-Updater.plist
org.macosforge.xquartz.startx.plist

~/Library/LaunchAgents Per-user agents provided by the user.
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 a signal SIGXFSZ to be generated; .
When the soft cpu time limit is exceeded, a signal 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 specified for rlp is invalid.
[EINVAL] resource is invalid.

The setrlimit() call will fail if:
[EINVAL] specified 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>

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)". SEE ALSO 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.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
    
    
    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 com.apple… plists include StartCalendarInterval as of 11/06/13 Mavericks:

    DiagnosticReportCleanUpDaemon 11:00
    ServerPerfLog.aslmanager      03:25 W=6 (Sunday)
    emond.aslmanager              
    bsd.dirhelper                 03:35
    gkreport                      03:52 w=5 (Saturday)
    locate                        03:15 w=6
    loginwindow.LFVTracer         00:15   6
    logkextloadsd                 14:20   2 Tuesday
    logsyswritesd                 03:15
    newsyslog                       :30
    systemstats.daily             00:15
    var-db-dslocal-backup         03:15   6
    
    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)