|
|
@ -1,34 +1,33 @@
|
|
|
|
# launchctl
|
|
|
|
# launchctl
|
|
|
|
|
|
|
|
|
|
|
|
# A command-line interface to Apple's launchd manager
|
|
|
|
# A command-line interface to Apple's launchd manager
|
|
|
|
# for launch daemons (system-wide services) and launch agents (per-user programs).
|
|
|
|
#
|
|
|
|
# launchd loads XML-based *.plist files placed in the appropriate locations,
|
|
|
|
# for launch daemons (system-wide services) and launch agents (per-user
|
|
|
|
# and runs the corresponding commands according to their defined schedule.
|
|
|
|
# programs). launchd loads XML-based *.plist files placed in the appropriate
|
|
|
|
|
|
|
|
# locations, and runs the corresponding commands according to their defined
|
|
|
|
|
|
|
|
# schedule.
|
|
|
|
|
|
|
|
|
|
|
|
# Activate a user-specific agent to be loaded into launchd
|
|
|
|
# Activate user-specific agent to load into launchd whenever the user logs in.
|
|
|
|
# whenever the user logs in:
|
|
|
|
|
|
|
|
launchctl load ~/Library/LaunchAgents/my_script.plist
|
|
|
|
launchctl load ~/Library/LaunchAgents/my_script.plist
|
|
|
|
|
|
|
|
|
|
|
|
# Activate an agent which requires root privileges to run
|
|
|
|
# Activate an agent which requires root privileges to run and/or should be
|
|
|
|
# and/or should be loaded whenever any user logs in (note the absence of ~ in the path):
|
|
|
|
# loaded whenever any user logs in (note the absence of ~ in the path).
|
|
|
|
sudo launchctl load /Library/LaunchAgents/root_script.plist
|
|
|
|
sudo launchctl load /Library/LaunchAgents/root_script.plist
|
|
|
|
|
|
|
|
|
|
|
|
# Activate a system-wide daemon to be loaded
|
|
|
|
# Activate a system-wide daemon to be loaded whenever the system boots up, -
|
|
|
|
# whenever the system boots up (even if no user logs in):
|
|
|
|
# even if no user logs in.
|
|
|
|
sudo launchctl load /Library/LaunchDaemons/system_daemon.plist
|
|
|
|
sudo launchctl load /Library/LaunchDaemons/system_daemon.plist
|
|
|
|
|
|
|
|
|
|
|
|
# Show all loaded agents/daemons, with the PID if the process they specify is currently running,
|
|
|
|
# Show all loaded agents/daemons, with the PID if the process they specify is
|
|
|
|
# and the exit code returned the last time they ran:
|
|
|
|
# currently running, and the exit code returned the last time they ran.
|
|
|
|
launchctl list
|
|
|
|
launchctl list
|
|
|
|
|
|
|
|
|
|
|
|
# Unload a currently loaded agent, e.g. to make changes
|
|
|
|
# Unload a currently-loaded agent to, for example, make changes. The plist file
|
|
|
|
# (note: the plist file is automatically loaded into launchd after a reboot and/or logging in):
|
|
|
|
# is automatically loaded into launchd after a reboot and/or logging in.
|
|
|
|
launchctl unload ~/Library/LaunchAgents/my_script.plist
|
|
|
|
launchctl unload ~/Library/LaunchAgents/my_script.plist
|
|
|
|
|
|
|
|
|
|
|
|
# Manually run a known (loaded) agent/daemon, even if it isn’t the right time
|
|
|
|
# Manually run a known (loaded) agent/daemon, even if it isn’t the right time
|
|
|
|
# (note: this command uses the agent's label, rather than the filename):
|
|
|
|
# This command uses the agent's label, rather than the filename.
|
|
|
|
launchctl start my_script
|
|
|
|
launchctl start my_script
|
|
|
|
|
|
|
|
|
|
|
|
# Manually kill the process associated with a known agent/daemon, if it's running:
|
|
|
|
# Manually kill the process associated with a known agent/daemon, if running.
|
|
|
|
launchctl stop my_script
|
|
|
|
launchctl stop my_script
|
|
|
|
|
|
|
|
|
|
|
|