Hi, I would like to know how I could get the number of processes for each user that is currently logged in. Thank you.
+2
A:
You could try some variation of this:
ps haux Ou | cut '-d ' -f1 | uniq -c
It gives you the number of processes for each users (being logged in or not). Now you could filter those results using the output of the w command or another way of determining who is logged in.
Helmut
2010-10-06 16:28:10
Nice! Could add a `grep ' pts\| tty'` before the cut, would cut out any process not tied to a terminal.
zigdon
2010-10-06 16:34:28
A:
"ps -u aboelnour | awk 'END {print NR}'"
will show number of process which user aboelnour running it
Aboelnour
2010-10-06 16:30:11
A:
Following links contain useful ps commands options including your requirements:
NAVEED
2010-10-06 16:32:13
A:
userlist=$(w|awk 'BEGIN{ORS=","}NR>2{print $1}'|sed 's/,$//' )
ps -u "$userlist"
ghostdog74
2010-10-06 16:33:03
I have used this in combination with Aboelnour's answer but it gives me the number of processes without the corresponding user of those processes.Any idea on how I could fix this?
Vidi
2010-10-06 17:07:49
+1
A:
Give this a try:
ps -u "$(echo $(w -h | cut -d ' ' -f1 | sort -u))" o user= | sort | uniq -c | sort -rn
Dennis Williamson
2010-10-06 18:13:33