Find a PID with ps + awk

This is really something i need to learn, and never forget. But this is kind of stuff, I always forget. So I write it up right now.

ps aux|gawk '$11 == "ssh" {print $2}'

Related posts :

admin November 15th, 2004


6 Responses to “Find a PID with ps + awk”

  1. gwennon 16 Nov 2004 at 12:57 pm

    There’s the pidof command too :

    $ pidof ssh
    26304 23541 18200
    
  2. Jkxon 16 Nov 2004 at 6:59 pm

    I don’t remember exactly why, but last time, pidof doesn’t work for me. and awk does .. Anyway, this can be a quick awk introduction

  3. Jkxon 19 Nov 2004 at 12:21 am

    Somebody tells me that pidof isn’t portable too .. :)

  4. Anonymouson 06 Jun 2006 at 7:04 pm

    pidof is only valid in Linux and maybe not every distro.

  5. btisdallon 09 Aug 2006 at 8:37 pm

    not forgetting pgrep…

  6. kpdon 12 Feb 2007 at 3:54 pm

    Cool. Thanks. It’s been on my when I get around to it list for a long time.

Comments RSS

Leave a Reply