pidof



  • 0_1495958134976_pidof.png

    Used for: Finding the process ids of running processes.
    pidof man page: http://bit.ly/2ru0vIN

    Notes:

    • Used in system-V init scripts.
    • pidof is a link to killall5
    $ ls -l /sbin/pidof 
    lrwxrwxrwx. 1 root root 18 May 24 22:03 /sbin/pidof -> /usr/sbin/killall5
    
    First Option Description
    -s Only return one pid
    -c For root user, return the process id's of processes which have the same root directory
    -n Do not run on NFS, alternatively set PIDOF_NETFS environment variable.
    -x find process id's of scripts.
    -o ignore process id, can use the %PPID to omit the parent process id

    Find all process id's of python.

    $ pidof python
    1429 846
    

    Find all process id's of python and sshd.

    $ pidof python sshd
    1429 846 1456
    

    Find python process id's, but only return the first one found.

    $ pidof -s python
    1429
    

    Exclude a process id from the list.

    $ pidof -o 1429 python
    846
    

    pgrep is favoured over pidof. In the Unix & Linux world, as we know, there are multiple ways to achieve your end goal.

    pgrep man page: http://bit.ly/2rLnQW6
    killall5 man page: http://bit.ly/2qoosRP


Log in to reply
 

© Lightnetics 2024