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:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins

- My 10 UNIX Command Line Mistakes
- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
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 }
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
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.
In OpenBSD it’s the gnuwatch command. It can be installed as a package or through the ports system (misc/gnuwatch).