On 29/05/06, Mark Clifford <markcliff at gmail.com> wrote:
> The top command looks like the correct value but how do i return it only
> through a shell script.
What arguments does your "top" accept?
-n 1 (one iteration only) will be helpful.
-b (batch mode) might be.
-u username or -U username (TFM) can save some post-processing.
You might also want a way to override .toprc, if your version supports
that. The aim is to get a consistent output format, of course.
When you've got the right number included in the output, either some
combination of grep and
tr -s ' ' | cut -d ' ' -f 5 (for suitable values of 5)
or awk to better confine the grep pattern matches should allow you to
isolate the number you want.
Whether "top" is the right tool is a separate question; if you're
happy that it is, then the above should allow you to use it.
All the best,
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!