watch Command

While researching some issues I’m having with iostat, I found an interesting command called ‘watch’

Instead of running the usual command (up arrow, return, up arrow, return)

[cce][[email protected] ~]# cat /proc/diskstats | grep “sda ”
8 0 sda 42113 18004 1395004 80723 18000492 45624354 508998694 7650613 0 4953776 7730941
[[email protected] ~]# cat /proc/diskstats | grep “sda ”
8 0 sda 42113 18004 1395004 80723 18000492 45624354 508998694 7650613 0 4953776 7730941
[[email protected] ~]# cat /proc/diskstats | grep “sda ”
8 0 sda 42113 18004 1395004 80723 18000497 45624372 508998878 7650614 0 4953777 7730942[/cce]

…or writing a never ending while loop. You can issue “watch” which will run your program (clearing the screen each time) and even show you (highlighted) the diffs between each call … pretty nice:

[cce][[email protected] ~]# watch -n 1 -d ‘cat /proc/diskstats | grep “sda “‘[/cce]

would show in a new screen:
[cce]Every 1.0s: cat /proc/diskstats | grep “sda ” Mon Dec 7 09:42:18 2009

8 0 sda 42113 18004 1395004 80723 18000540 45624456 508999894 7650638 0 4953787 7730966[/cce]