How do I monitor Linux/BSD system over time without scrolling output?

by nixcraft on March 27, 2006 · 3 comments

Suppose you would like to monitor memory utilization over time without having to look at scrolling output or disk space without scrolling output then normal commands do not provide any options.

You need to use watch command, which execute a program periodically, showing output in fullscreen mode. It runs command repeatedly, displaying its output. This allows you to watch the program output change over time. By default, the program is run every 2 seconds.

To watch memory usage:

$ watch free -m

Run free –m program is run every 5 seconds:

$ watch -n 5 free -m

To watch disk space usage:

$ watch df -h

To watch the contents of a directory change, you could use:

$ watch -d ls –l

Options:

  • The -d flag will highlight the differences between successive updates.
  • The –n {SECOND} flag use to specify a different interval.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 3 comments… read them below or add one }

1 Anonymous September 22, 2006

that doesnt work in bsd. im searching for the solution right now, just letting you know that watch in open and freebsd does something else than it does in linux

Reply

2 John February 27, 2007

For FreeBSD:

cd /usr/ports/sysutils/cmdwatch && make install clean

then substitute cmdwatch for watch as listed above.

The other BSD’s should be very similar.
The stock BSD watch is for snooping on other tty’s (which can be rather useful too :-D ).

But thx for this, it’s helpful to keep an eye on httpd errors, during web development, as well as busloads of other tasks.

Reply

3 David February 23, 2009

In OpenBSD it’s the gnuwatch command. It can be installed as a package or through the ports system (misc/gnuwatch).

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 10 + 14 ?
Please leave these two fields as-is:
Are you a human being? Solve the simple math so we know that you are a human and not a bot.



Previous post:

Next post: