Linux/Unix command to determine if process is running?

后端 未结 14 959
忘掉有多难
忘掉有多难 2020-11-28 01:54

I need a platform independent (Linux/Unix|OSX) shell/bash command that will determine if a specific process is running. e.g. mysqld, httpd... What

14条回答
  •  渐次进展
    2020-11-28 02:34

    This should work on most flavours of Unix, BSD and Linux:

    PATH=/usr/ucb:${PATH} ps aux | grep httpd | grep -v grep
    

    Tested on:

    • SunOS 5.10 [Hence the PATH=...]
    • Linux 2.6.32 (CentOS)
    • Linux 3.0.0 (Ubuntu)
    • Darwin 11.2.0
    • FreeBSD 9.0-STABLE
    • Red Hat Enterprise Linux ES release 4
    • Red Hat Enterprise Linux Server release 5

提交回复
热议问题