Results 1 to 3 of 3
  1. #1

    httpd processes running top or ps?

    okay.. so here is a simple question that i just can't seem to figure out.. when i run the command top or ps -auxw.. they show the httpd processes as the command httpd or /usr/sbin/httpd, but how do i know what file that is? is there anyway to find out what file that is actually getting executed or served?
    http://limehosting.com

  2. #2
    As root: readlink /proc/pid/exe

    where "pid" is the process id of the process. Example below using process id 4337:

    PHP Code:
    # ps aux | grep httpd | head -1
    root      4337  0.0  0.9  15056  6996 ?        Ss   Jan21   0:00 /usr/local/apache2/bin/httpd -k start 
    PHP Code:
    # readlink /proc/4337/exe
    /usr/local/apache2/bin/httpd 
    Another way is via the "lsof" command:

    PHP Code:
    # /usr/sbin/lsof -p 4337
    COMMAND  PID USER   FD   TYPE DEVICE     SIZE    NODE NAME
    httpd   4337 root  cwd    DIR  253
    ,0     4096       2 /
    httpd   4337 root  rtd    DIR  253,0     4096       2 /
    httpd   4337 root  txt    REG  253,0  2518097 2950220 /usr/local/apache2/bin/httpd
    httpd   4337 root  mem    REG  253
    ,0  1241936 7734106 /lib/libcrypto.so.0.9.8b
    httpd   4337 root  mem    REG  253
    ,0   281180 7734107 /lib/libssl.so.0.9.8b
    [ ... ] 
    You can also get more info on a process by snooping around in the /proc/pid directory for the process:

    PHP Code:
    # cd /proc/4337/

    # ls -al
    total 0
    dr
    -xr-xr-x  5 root root 0 Jan 24 22:07 .
    dr-xr-xr-x 86 root root 0 Jan 21 04:02 ..
    dr-xr-xr-x  2 root root 0 Feb  5 02:29 attr
    -r--------  1 root root 0 Feb  5 02:29 auxv
    -r--r--r--  1 root root 0 Feb  5 02:14 cmdline
    -r--r--r--  1 root root 0 Feb  5 02:29 cpuset
    lrwxrwxrwx  1 root root 0 Feb  2 16
    :48 cwd -> /
    -
    r--------  1 root root 0 Feb  5 02:29 environ
    lrwxrwxrwx  1 root root 0 Feb  2 16
    :48 exe -> /usr/local/apache2/bin/httpd
    dr
    -x------  2 root root 0 Jan 25 22:00 fd
    -rw-r--r--  1 root root 0 Feb  5 02:29 loginuid
    -r--r--r--  1 root root 0 Feb  2 16:48 maps
    -rw-------  1 root root 0 Feb  5 02:29 mem
    -r--r--r--  1 root root 0 Feb  5 02:29 mounts
    -r--------  1 root root 0 Feb  5 02:29 mountstats
    -rw-r--r--  1 root root 0 Feb  5 02:29 oom_adj
    -r--r--r--  1 root root 0 Feb  5 02:29 oom_score
    lrwxrwxrwx  1 root root 0 Feb  2 16
    :48 root -> /
    -
    r--r--r--  1 root root 0 Feb  5 02:29 schedstat
    -r--------  1 root root 0 Feb  5 02:29 smaps
    -r--r--r--  1 root root 0 Feb  5 02:14 stat
    -r--r--r--  1 root root 0 Feb  5 02:29 statm
    -r--r--r--  1 root root 0 Feb  5 02:14 status
    dr
    -xr-xr-x  3 root root 0 Jan 25 22:00 task
    -r--r--r--  1 root root 0 Feb  5 02:29 wchan

    # strings cmdline
    /usr/local/apache2/bin/httpd
    start

    # strings stat
    4337 (httpdS 1 4337 4337 0 -1 4202560 757 0 0 0 22 8 0 0 18 0 1 0 4683963 15417344 1749 4294967295 134512640 135161704 3216445056 3216444236 4834306 0 0 4096 134235883 0 0 0 17 0 0 0 0

    # strings environ
    [ ... ] 
    You can also include the "e" argument to ps auxw to show some environmental information about the pid:

    PHP Code:
    # ps auxwe | grep 4337
    lots of output here 
    Want to learn more about what a process is doing? Use the "strace" command:

    PHP Code:
    # strace -f -p 4337
    Process 4337 attached interrupt to quit
    select
    (0NULLNULLNULL, {0487000}) = (Timeout)
    waitpid(-10xbfb70b68WNOHANG|WSTOPPED) = 0
    [ ... ] 
    ctrl+c will stop the tracing of the process. Likewise, you can use ltrace to observe library action from the process:

    PHP Code:
    # ltrace -f -p 4337
    apr_proc_wait_all_procs(0xbfb70d240xbfb70d340xbfb70d3810x9e25550)                        = 70006
    apr_sleep
    (0xf424000xbfb70d3810x9e25550 <unfinished ...>
    [ ... ] 

  3. #3
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    Quote Originally Posted by joeshacks View Post
    okay.. so here is a simple question that i just can't seem to figure out.. when i run the command top or ps -auxw.. they show the httpd processes as the command httpd or /usr/sbin/httpd, but how do i know what file that is? is there anyway to find out what file that is actually getting executed or served?
    You can check the apache access_logs/error_log to see which all files are served currently.

    tail -f /usr/local/apache/log/access_logs
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •