You can use the watch command to execute a program or shell script periodically, display its output on screen repeatedly. This allows you to watch the program output change over time. By default, the program is run every 2 seconds. This is useful to monitor memory utilization or disk space usage over time without having to look at scrolling output.
Say hello to watch command
The watch command execute a program periodically, showing output in fullscreen mode. It runs command repeatedly, displaying its output. You can install gnuwatch under OpenBSD or cmdwatch under FreeBSD (see the comments for more information) to get the same result.
watch command examples
To watch memory usage, enter:
watch free -m
To run free –m program every 5 seconds, enter:
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
Where,
- The -d flag will highlight the differences between successive updates.
- The –n {SECOND} flag use to specify a different interval.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop



![Sending Email With Attachments From Unix / Linux Command [ Shell Prompt ]](http://s13.cyberciti.org/images/shared/rp/3/10.jpg)








{ 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).