AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
Expand all | Collapse all

Find out the process id without having to install lsof in AIX

  • 1.  Find out the process id without having to install lsof in AIX

    Posted Thu September 16, 2010 02:03 PM

    Originally posted by: Jaikishan


    This abstract illustrates the steps to find out the process id by using the port number that may help the AIX System Administrators without having to install lsof.

    The past experiences have shown troubles to compile the source in certain versions of AIX(v5.3) and otherwise. Therefore the attached script will help achieve the same as lsof utility does.

    Some times we know the port number and may want to kill the process manually. This can be achieved using lsof command. However, past experiences show that lsof command has troubles installing/compiling particularly with certain versions of AIX. Sometimes the source of lsof compiles properly and most of the times it does not.

    Therefore, to get away the use of lsof command the steps mentioned in the solution description will help find out the process id without hassles.

    Before you begin to execute this script you should know the port number and check if the port number is being listened. Use the command :
    netstat -an | grep "<port_number>"

    The attached script "processid_from_portno.sh" which accepts port number as input and gives process id as output.
    Also attached is the sample screenshot for executing the above script
    Step 1. Find out the address of the port number

    1. netstat -Aa | pg
    output will be something like :
    f100060003606b98 tcp4 0 0 *.51063 . LISTEN
    f100060003489398 tcp4 0 0 *.51100 . LISTEN
    f1000600035ed398 tcp4 0 0 *.51101 . LISTEN

    Step 2. Take the hex address for the port number e.g. 51063

    Step 3. Use sockinfo command

    1. echo "sockinfo f100060003606b98 tcpcb" | kdb |grep proc
    the output will be something like this :
    F100070F00000000 F100070F10000000 pvproc+000000
    proc/fd: 16463/562
    proc/fd: fd: 562
    pvproc+1013C00 16463*java ACTIVE 004F1E4 0000001 0000000147AF6400 0 0037

    Step 4. Convert the hex value to decimal

    1. echo "hcal 004F1E4"|kdb|grep Value
    output will be:
    Value hexa: 0004F1E4 Value decimal: 324068

    Step 5. Find out the process id now

    1. ps -fp 324068
    output will be:
    UID PID PPID C STIME TTY TIME CMD
    root 324068 1 0 Jan 17 - 8:06 /usr/WebSphere/p11/AppServer//java/bin/java -Djava.net.preferIPv4Stack=t
    #AIX-Forum


  • 2.  Re: Find out the process id without having to install lsof in AIX

    Posted Tue September 21, 2010 10:09 AM

    Originally posted by: SystemAdmin


    Thank you very much for this. This will be useful on servers I don't have lsof on.

    Regards,
    Tony
    #AIX-Forum


  • 3.  Re: Find out the process id without having to install lsof in AIX

    Posted Tue September 21, 2010 10:37 AM

    Originally posted by: MarkTaylor


    or .. rmsock <pcb address> tcpcb ## saves you having to convert pid in hex to dec

    HTH
    Mark Taylor
    #AIX-Forum