Notepad/enter/Coding Tips (Classical)/Terminal Tips/Shells/Computers (operating system)/Apple Macbook/Launchd.md

83 lines
1.8 KiB
Markdown
Raw Normal View History

2023-07-14 20:02:45 +00:00
A MacOS specific version of a [cron](obsidian://open?vault=enter&file=Coding%20Tips%20(Classical)%2FTerminal%20Tips%2FShells%2FComputers%20(operating%20system)%2FLinux%2FCrontab) that automates scripts and programs.
In computing, **launchd**, a unified operating system service management framework, starts, stops and manages daemons, applications, processes, and scripts in macOS. It was introduced with Mac OS X Tiger and is licensed under the Apache License —Wikipedia
Here are some helpful tips;
View Services
```
sudo launchctl list
```
without Sudo
```
$ sudo launchctl list | grep ssh
- 0 com.openssh.sshd
$ launchctl list | grep ssh
3521 0 com.openssh.ssh-agent
```
Particular Service details
```
$ sudo launchctl list com.openssh.sshd
{
"Wait" = false;
"Sockets" = {
"Listeners" = (
file-descriptor-object;
file-descriptor-object;
);
};
"LimitLoadToSessionType" = "System";
"StandardErrorPath" = "/dev/null";
"Label" = "com.openssh.sshd";
"inetdCompatibility" = true;
"OnDemand" = true;
"LastExitStatus" = 0;
"Program" = "/usr/libexec/sshd-keygen-wrapper";
"ProgramArguments" = (
"/usr/sbin/sshd";
"-i";
);
};
```
Stop and start service:
```
sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd
```
Service definition via print:
```
sudo launchctl print system/com.openssh.sshd
```
Loading Services
```
# load
sudo launchctl load /System/Library/LaunchDaemons/ssh.plist
# enable
sudo launchctl enable system/com.openssh.sshd
# disable
sudo launchctl disable system/com.openssh.sshd
# unload
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
```
via [Rakesh](https://rakhesh.com/mac/macos-launchctl-commands/)
A great launchd blog [post on here too. ](https://ellismin.com/2020/03/launchd-1/)