Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the status(running/stopped) of a process/daemon in Mac?

Tags:

macos

In Linux, we have the command /etc/init.d/process_name status, this will give whether the process/daemon is running or stopped.

For Example In Ubuntu:

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?

like image 513
user389547 Avatar asked Aug 07 '10 12:08

user389547


People also ask

How do I check SSH status on Mac?

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”.


2 Answers

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
like image 92
Christopher Creutzig Avatar answered Sep 24 '22 17:09

Christopher Creutzig


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;
        );
    };
};
like image 37
Scott Robert Schreckengaust Avatar answered Sep 20 '22 17:09

Scott Robert Schreckengaust