Forrest logo
tool overview
On this page you find all important commands for the CLI tool launchctl. If the command you are looking for is missing please ask our AI.

launchctl

Launchctl is a command-line tool used in macOS and other Unix-like operating systems to manage system-wide and user-specific daemons, services, and processes. It is responsible for loading and unloading these services at designated times and managing the overall system's init and launch process. With launchctl, administrators can control the initialization and operation of Unix services, applications, and various background processes.

The tool helps maintain the stability, performance, and control of the system by executing and managing launchd, the system-wide process manager. Administrators can use launchctl to start, stop, or examine daemons and agents, enabling efficient management of system activities.

It supports various options and commands, including load to start a daemon, unload to stop a daemon, list to show active daemons, and remove to delete unwanted or unused services. Additionally, it allows for controlling the job scheduling, enabling delayed or periodic execution of jobs at specified times.

Launchctl plays a crucial role in maintaining the system's integrity, managing user-specific services, and providing flexible control over the initialization and management of various processes, boosting the overall efficiency of the operating system.

List of commands for launchctl:

  • launchctl:tldr:16024 launchctl: Show all loaded agents/daemons, with the PID if the process they specify is currently running, and the exit code returned the last time they ran.
    $ launchctl list
    try on your machine
    explain this command
  • launchctl:tldr:50e2c launchctl: Unload a currently loaded agent, e.g. to make changes (note: the plist file is automatically loaded into `launchd` after a reboot and/or logging in).
    $ launchctl unload ~/Library/LaunchAgents/${my_script}.plist
    try on your machine
    explain this command
  • launchctl:tldr:77656 launchctl: Manually kill the process associated with a known agent/daemon, if it is running.
    $ launchctl stop ${script_file}
    try on your machine
    explain this command
  • launchctl:tldr:8c7ed launchctl: Manually run a known (loaded) agent/daemon, even if it is not the right time (note: this command uses the agent's label, rather than the filename).
    $ launchctl start ${script_file}
    try on your machine
    explain this command
  • launchctl:tldr:9612f launchctl: Activate an agent which requires root privileges to run and/or should be loaded whenever any user logs in (note the absence of `~` in the path).
    $ sudo launchctl load /Library/LaunchAgents/${root_script}.plist
    try on your machine
    explain this command
  • launchctl:tldr:b5aed launchctl: Activate a user-specific agent to be loaded into `launchd` whenever the user logs in.
    $ launchctl load ~/Library/LaunchAgents/${my_script}.plist
    try on your machine
    explain this command
  • launchctl:tldr:ba9b9 launchctl: Activate a system-wide daemon to be loaded whenever the system boots up (even if no user logs in).
    $ sudo launchctl load /Library/LaunchDaemons/${system_daemon}.plist
    try on your machine
    explain this command
tool overview