The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PID running directory

Discussion in 'General Discussion' started by alifazman, Dec 28, 2010.

  1. alifazman

    alifazman Active Member

    Joined:
    Sep 27, 2010
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Malaysia
    Hi All.

    How do I check the working directory for example PID :1234. Is it any way to detect in through ssh command /cPanel

    Thanks ya!!
     
  2. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You can get information about a PID, including its current working directory, by looking in the corresponding subdirectory in /proc. Each running PID has its own directory in /proc. Simply use the ls command to view the contents of /proc/$PID (where $PID is replaced with an actual valid PID).
     
  3. garrettp

    garrettp Well-Known Member
    PartnerNOC

    Joined:
    Jun 18, 2004
    Messages:
    312
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    DataCenter Provider
    Similarly and perhaps a bit more readable, you can get the cwd of a process using it's PID through lsof. It also will provide information about currently open (or listening) connections, sockets, and open files.

    Code:
    lsof -p <pid>
     
  4. JeffP.

    JeffP. Well-Known Member

    Joined:
    Sep 28, 2010
    Messages:
    164
    Likes Received:
    9
    Trophy Points:
    18
    Yet another way is via the "readlink" command:

    # readlink /proc/`pgrep cpsrvd`/cwd
    /usr/local/cpanel/base
     
  5. alifazman

    alifazman Active Member

    Joined:
    Sep 27, 2010
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Malaysia
    Hello all,

    Thanks for all those information. It helps me ;)

    Happy new year to all ;D
     
Loading...

Share This Page