Linux/Unix command to determine if process is running?

后端 未结 14 1002
忘掉有多难
忘掉有多难 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:22

    Just a minor addition: if you add the -c flag to ps, you don't need to remove the line containing the grep process with grep -v afterwards. I.e.

    ps acux | grep cron
    

    is all the typing you'll need on a bsd-ish system (this includes MacOSX) You can leave the -u away if you need less information.

    On a system where the genetics of the native ps command point back to SysV, you'd use

    ps -e |grep cron
    

    or

    ps -el |grep cron 
    

    for a listing containing more than just pid and process name. Of course you could select the specific fields to print out using the -o option.

提交回复
热议问题