In Linux, we have the command /etc/init.d/process_name status
, this will give whether the process/daemon is running or stopped.
root@Ubu91032b-Bassu:~# /etc/init.d/ssh status
* sshd is running
root@Ubu91032b-Bassu:~#
My question is, is there any command (like above) in Mac to check the status of a daemon/process?
Check SSH status on MacIf the remote login and SSH is currently enabled, the output will say “Remote Login: On” If SSH is disabled, it will say “Remote Login: Off”.
The documented “modern” way would, I believe, be to ask launchctl
, the controlling tool for launchd
, which Apple uses to replace init
, inetd
, crond
and a bit more:
~> sudo launchctl list | grep ssh
41032 - 0x100502860.anonymous.sshd
- 0 com.openssh.sshd
To toggle remote login use the "System Preferences" => "Sharing" => "Remote Login" via the user interface to enable SSH (see http://support.apple.com/kb/PH13759 for more).
Remote Login via SSH Disabled (Unchecked):
$ sudo launchctl list com.openssh.sshd
launchctl list returned unknown response
Remote Login via SSH Enabled (Checked):
$ sudo launchctl list com.openssh.sshd
{
"Label" = "com.openssh.sshd";
"LimitLoadToSessionType" = "System";
"OnDemand" = true;
"LastExitStatus" = 0;
"TimeOut" = 30;
"Program" = "/usr/libexec/sshd-keygen-wrapper";
"StandardErrorPath" = "/dev/null";
"ProgramArguments" = (
"/usr/sbin/sshd";
"-i";
);
"inetdCompatibility" = {
"Wait" = false;
};
"Sockets" = {
"Listeners" = (
file-descriptor-object;
file-descriptor-object;
);
};
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With