launchctl [subcommand [arguments …]]
without arguments enters command mode (no line editing)

Mac OS X uses launchctl to control launchd including configuration and requests to load, unload daemons/agents.

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>

includes:

These commands can be stored in
$HOME/.launchd.conf or
/etc/launchd.conf to be read at the time launchd starts.

list joblabel
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;
  };
}; 
/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;
  };
};
load
   [-Fw] paths
Load configuration files (example: com.apple.dpd.plist) or
directories of configuration files.
      -F Force the loading of the plist. Ignore Disabled
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
   [-w]
   [-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
       -w depricated: Add the disabled keyword to plist and
write the configuration files .
        -S sessiontype Look for jobs in a different location when using -D , and allows launchctl to restrict which jobs are loaded into which session types.
Aqua, LoginWindow, Background, StandardIO and System.
       -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 given, -D system would load from property list files from
/System/Library/LaunchDaemons.
With a session type passed, it would load from
/System/Library/LaunchAgents.
start joblabels …
stop  joblabels …
start,
stop the specified jobs by label.
Jobs may restart automatically if demand driven.
 
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
bootstrap
singleuserHappens instantly without confirmation!
bsexec Execute a process within a different Mach bootstrap subset
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
[both |
[soft hard]]
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 )
help  
[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

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
     …

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

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

gbootps
†ATSServer
†AppleFileServer
†CoreRAID
†DirectoryServices
†DirectoryServicesLocal
†DumpPanic
†FileSyncAgent.sshd
†IFCStart
†IIDCAssistant
†InternetSharing
†KerberosAutoConfig
†KernelEventAgent
†ODSAgent
†RFBRegisterMDNS_RemoteManagement
†RFBRegisterMDNS_ScreenSharing
†RemoteDesktop.PrivilegeProxy
†ReportCrash.DirectoryService
†ReportCrash.SafetyNet
†ReportCrash
†SystemStarter
†UserNotificationCenter
†WindowServer
†airport.wps
†airportPrefsUpdater
†airportd
†alf.agent
†atrun
†audio.coreaudiod
†autofsd
†automountd
†backupd-attach
†backupd-auto
†backupd
†blued
†bootlog
†bsd.dirhelper
†configd
†configureLocalKDC
†coreservicesd
†dashboard.advisory.fetch
†diskarbitrationd
†distnoted
†dnsextd
†docsetinstalld
†dyld
†dynamic_pager
†efax
†familycontrols
†firmwaresyncd
†fseventsd
†gssd
†hdiejectd
†hidd
†installdb.system
†java.updateSharingD
†kdcmond
†kdumpd
†kextd
†kuncd
†locate
†lockd
†loginwindow
†mDNSResponder
†mDNSResponderHelper
†metadata.mds
†mio.AVCAssistant
†mio.IIDCVideoAssistant
†mio.VDCAssistant
†netauth.sysagent
†newsyslog
†nfsd
†nis.rpc.yppasswdd
†nis.ypbind
†nis.ypserv
†notifyd
†ocspd
†pcastagentd
†periodic-daily
†periodic-daily.plist~
†periodic-monthly
†periodic-weekly
†portmap
†scsid
†seatbelt.compilerd
†securityd
†service_helper
†smb.server.preferences
†smbfs_load_kext
†spindump
†stackshot
†statd.notify
†syslogd
†systemkeychain
†taskgated
†update
†usbmuxd
†uucp
†webfilter
†xgridagentd
†xgridcontrollerd
com.vix.cron
gcomsat
geppc
gexec
gfinger
gftp
glogin
gnmbd
gntalk
org.amavis.amavisd
org.apache.httpd
org.cups.cups-lpd
org.cups.cupsd
org.isc.named
org.net-snmp.snmpd
org.ntp.ntpd
org.postfix.master
org.samba.winbindd
gshell
gsmbd
gssh
gtelnet
gtftp
/Library/LaunchAgents Per-user agents provided by the administrator.
empty smacker 3/17/08
~/Library/LaunchAgents Per-user agents provided by the user.
empty smacker 3/17/08
/Library/LaunchDaemons System wide daemons provided by the administratori
Causes icon to appear in menubar
465 Sep 28 03:57 com.sophos.intercheck.plist
477 Sep 28 03:58 com.sophos.notification.plist
477 Oct  6 03:34 com.sophos.autoupdate.plist
553 Oct 27 13:37 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>
        
  
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

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


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 mysqld get started on OSX?

  1. Get process id:

    Following icom.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