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)
1 2 3 4 5 6 | [root@nms-tpt-1 ~]# cat /proc/diskstats | grep "sda " 8 0 sda 42113 18004 1395004 80723 18000492 45624354 508998694 7650613 0 4953776 7730941 [root@nms-tpt-1 ~]# cat /proc/diskstats | grep "sda " 8 0 sda 42113 18004 1395004 80723 18000492 45624354 508998694 7650613 0 4953776 7730941 [root@nms-tpt-1 ~]# cat /proc/diskstats | grep "sda " 8 0 sda 42113 18004 1395004 80723 18000497 45624372 508998878 7650614 0 4953777 7730942 |
…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:
1 | [root@nms-tpt-1 ~]# watch -n 1 -d 'cat /proc/diskstats | grep "sda "' |
would show in a new screen:
1 2 3 | 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 |





