ps: Clean way to only get parent processes?

后端 未结 9 743
忘了有多久
忘了有多久 2020-12-15 00:28

I use ps ef and ps rf a lot.

Here is a sample output for ps rf:

  PID TTY      STAT   TIME COMMAND
 3476 pts/0         


        
相关标签:
9条回答
  • 2020-12-15 01:19
    /usr/bin/pgrep -o <process_name>
    

    where '-o' is the oldest (least recently started) of the matching processes

    0 讨论(0)
  • 2020-12-15 01:19

    how about ps fuxa | grep 'PID\|[0-9] /' for all parents, or: ps fuxa | grep '[0-9] /' | grep 'PID\|<commandname>' for single process?

    0 讨论(0)
  • 2020-12-15 01:19

    From key words KEYWORD

    ps aux | grep -i KEYWORD | grep -v grep | awk '{print $2}'|sort -h|head -1|xargs kill
    

    BTW, is this assumption that parent process ID is the smallest ID valid????

    0 讨论(0)
提交回复
热议问题