How to display what processes, users have opened at a given time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to display what processes, users have opened at a given time
# 1  
Old 11-02-2009
How to display what processes, users have opened at a given time

Hello,

What i have to do is make a top 10 list of users sorted by the number of processes opened at a given time. Can anyone help me with finding out for a given moment, for all users how many processes each had opened?
# 2  
Old 11-02-2009
Code:
who | awk '{print $1}' > t.sed; ps -ef | grep -f t.sed | awk '{arr[$1]++} END{ for (i in arr){print arr[i], i}}' | sort -rn

If this is homework, your prof is not likely to believe you wrote this...
# 3  
Old 11-02-2009
And he really doesn't Smilie

But i am now trying to disect the line and to figure out what you wrote there
# 4  
Old 11-02-2009
You could also start with "lsof" and (with some filtering and sorting, of course) have a lot more information about what the processes are actually doing. If it's just a homework assignment, doing something interesting with that should really impress your prof :-)
# 5  
Old 11-02-2009
who | awk '{print $1}' > file.txt
sort file.txt | uniq > file.txt
echo ' ' > results.txt
w > file2.txt
for i in `cat file.txt`
do
x=`grep -c $i file2.txt`
echo $x $i >> results.txt
done
sort -r results.txt > results2.txt
head -10 results2.txt > results.txt


This was my version and my teacher suggested i do it in one line.
So it's back to the drawing board Smilie
# 6  
Old 11-02-2009
I'm sorry, but for homework questions there's a special subforum. If your question hasn't already been answered, please repost there.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to display processes which have been running for more than a X hours?

Hi, Is it possible to display processes which have been running for more than a 5hrs using a variation of the ps -ef command? Regards, Manny (5 Replies)
Discussion started by: mantas44
5 Replies

2. Homework & Coursework Questions

Display info about users (UID GID processes terminal)

I would like to get an opinion for my solution for this task and get feedback about better approach or mistakes I have made. 1. The problem statement, all variables and given/known data: The task is to create a script which prints information about users whose names are specified in the... (2 Replies)
Discussion started by: kornfan
2 Replies

3. Shell Programming and Scripting

Scripting Help - Display Processes

Hi, I was wondering if somebody could help me as I am struggling with writing a script for a training course. Ive had to write 5 scripts and this is the last one but am struggling with this even though I understand what it is meant to do..... PROBLEM: write a script which will allow you to... (1 Reply)
Discussion started by: isxrc
1 Replies

4. UNIX for Advanced & Expert Users

same file being opened by two users at a time

I want to avoid a situation where because two users simultaneously open a file and modify and save, leaving the original file in mess. Is there a way in UNIX to warn a user if that particular file is already being used by another user. Thanks in advance (3 Replies)
Discussion started by: paresh n doshi
3 Replies

5. Shell Programming and Scripting

printing each users by processes

hello All, i am trying to get the each users by with thier processing. I have try it in several ways but i am not getting thier my code is #!bin/bash/ users=`cat /etc/passwd | cut -d':' -f5` onlineusers=`users | tr '.' ' '` $onlineusers | while read `$users` do echo `ps -U $users`... (12 Replies)
Discussion started by: sam4now
12 Replies

6. Shell Programming and Scripting

Processes and Users

Thx for all the help so far, I really appreciate it, this is the last task I have to do then I am no longer a trainee ^^, which means I can use whatever utility I want. :O I need to write a script that does more or less what is shown below. The Users Name PID TTY TIME CMD 12345 pts/3... (22 Replies)
Discussion started by: barbus
22 Replies

7. UNIX for Dummies Questions & Answers

users and there processes

I am trying to write a script to list all users and their processes. I cant seem to find out how to link the PID to the user. For example if i run ps -a I get a nice list of all the processes running and their PID, but no information about which user is running them. I need the users real name not... (3 Replies)
Discussion started by: iago
3 Replies

8. UNIX for Dummies Questions & Answers

Command to find last time file was opened

New to unix .. Is there a simple command or utility that will tell me when the last time a file was opened/used? (3 Replies)
Discussion started by: sbr262
3 Replies

9. Shell Programming and Scripting

Displaying the processes of users

Hi guys, I'm writing a script to display all the current logged on users and the processes they're running, output to a file. The output will look similar to this: User1 (Real name not login name) PID TTY TIME CMD 3179 pts/3 00:00:00 vim User2 PID TTY TIME ... (2 Replies)
Discussion started by: olimiles
2 Replies

10. UNIX for Dummies Questions & Answers

Users and processes

Hi All, I am trying to write a script to list all users and their processes. I cant seem to find out how to link the PID to the user. For example if i run ps -a I get a nice list of all the processes running and their PID, but no information about which user is running them. If i use w i... (17 Replies)
Discussion started by: Chiefos
17 Replies
Login or Register to Ask a Question