# Command for processes



## tifoz (Feb 3, 2010)

I need a command for listing:
 - number of current started processes,
 - percentage CPU usage and
 - cpu usage.

And save all that to some file. I found ps -u, but it has all kind of info that i dont need. Is it posibble to list only some info?
Thx.


----------



## Beastie (Feb 4, 2010)

`% top > outputfile` will work just fine too.
If you only need selected parts of the output, you can pipe it to awk(1), filter it with grep(1), edit it with sed(1), etc.


----------



## SirDice (Feb 4, 2010)

[cmd=]ps -ax | wc -l[/cmd]
and
[cmd=]vmstat[/cmd]


----------



## sixtydoses (Feb 4, 2010)

SirDice said:
			
		

> [cmd=]ps -ax | wc -l[/cmd]


minus head -1.


----------



## DutchDaemon (Feb 4, 2010)

Also look at the -o options in ps(1), e.g.


```
ps -e -o pcpu,cpu,nice,state,cputime,args
```
or go all out with

```
ps -ajguxww -o pcpu,cpu,nice,state,cputime,args
```


Pick, choose, cut and sort at will.


----------

