Results 1 to 5 of 5
Hi,
Can anyone tell me how to list the currently running processes via code a shell script. FYI i now about the top method in the terminal but i need ...
- 02-05-2011 #1Just Joined!
- Join Date
- Feb 2011
- Posts
- 3
Basic Shell Script Code
Hi,
Can anyone tell me how to list the currently running processes via code a shell script. FYI i now about the top method in the terminal but i need a way to have it via a shell script.
Any help appreciated
Thanks.
- 02-05-2011 #2
ps ax lists all running processes briefly. ps aux gives the same listing with more information. You could pipe it through awk to strip out and rearrange the specific information you require about processes.
"I'm just a little old lady; don't try to dazzle me with jargon!"
- 02-05-2011 #3Just Joined!
- Join Date
- Feb 2011
- Posts
- 3
Thanks. This is what i've got now so it outputs to a text file:
echo $(ps aux) >>out
It all works, but do you know if it is in any way possible to sort it so one process is on one line, making it more readable?
Thanks again.Last edited by acwest; 02-06-2011 at 08:08 AM.
- 02-06-2011 #4Just Joined!
- Join Date
- Feb 2011
- Posts
- 3
Does anyone know how to sort the output to a text file so that it prints to the text file at 1 proccess per line? I know it probably simple but im very new to linux.
- 02-06-2011 #5Just Joined!
- Join Date
- Mar 2010
- Posts
- 79
You don't need to use echo and put the command in $()-syntax.
That works here (while your code gives output like described by you).Code:ps ax > out.txt
If you use > it will overwrite existing content.
If you use >> it will append to existing content.


Reply With Quote