Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can you help me to find the PID's user name, Some time my server got high load. When i top -c, I cannot even find the PID's user name who / which is causing load on the server.

share|improve this question

migrated from stackoverflow.com Sep 26 '12 at 10:06

This question came from our site for professional and enthusiast programmers.

    
We were experiencing server load issue due to bulk php process, so that i had this question, we can then find them using 'lsof -p xxxx'. – Ranjithkumar T Jan 14 at 6:22

/proc/processID/status will have the information about user's ID which you can use to find the username.

This does the same:

uid=$(awk '/^Uid:/{print $2}' /proc/YOUR_PROCESS_ID/status)
getent passwd "$uid" | awk -F: '{print $1}'

Replace YOUR_PROCESS_ID with your process ID number.

share|improve this answer

I'm surprised nobody has put this up yet:

Try the -p option to the ps command.

For instance, if you have PID 1234, run:

ps -u -p 1234

(The -u was added to include the username in the output)

You can the use grep or awk, etc. to extract the info you want.

share|improve this answer
    
You were a tick faster than me. You're waking up earlier? Depending on the Linux distrbution, ps u 1234 (Debian) or just ps 1234 (Android with Busybox) also works. – ott-- Jan 10 at 7:02

What do you want exactly? On my system, if I run 'top -c' I get:

  PID USER      PR  NI  VIRT  RES  SHR S   %CPU %MEM    TIME+  COMMAND                                                                                                                        
  2873 matt      20   0 3022m 1.6g 1.6g S     22 21.6   2245:42 /usr/lib/virtualbox/VirtualBox --comment ESX5-1 --startvm 4fd78ee9-739a-4d53-a0ce-4f9819ab9411 --no-startvm-errormsgbox        
  29764matt      20   0 2779m 1.4g 1.3g S      5 18.4 210:33.51 /usr/lib/virtualbox/VirtualBox --comment win2008-2 --startvm 202ec2b7-ae12-40e9-af76-2be429e553d7 --no-startvm-errormsgbox     
  17281root      20   0     0    0    0 S      2  0.0   0:05.90 [kworker/u:2]                                                                                                              

So the PID (processus/task identifier) is the first column, and the user account the processus runs under is the second column

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.