Monitor your Linux box with the ” watch ” Command January 21, 2011Posted by Tournas Dimitrios in Linux.
watch command is a really neat tool which does a simple but incredibly useful thing: it repeatedly runs a given command line and shows you the output. So, you’re effectively monitoring a progress of some process by watching relevant files. The default interval is 2 seconds, which gives enough dynamics for most of the needs , but can also be customised . You can execute any Unix command using watch command . Watch command will be executed until you terminate it either by CTRL+C or kill the process.
watch is probably the most easy to use command line utility of the Linux operating system , with just a few switch options . This article will shows some practical examples . Of course the possibilities are endless , just use your imagination 🙂
|Practical examples with ” watch”|
||continuously check for failed “log-in” attempts|
|watch ‘ ls -lh /tmp |fgrep user1’||List all files that belongs to “user1”|
|watch ‘df -h |grep /dev/hda1 |tee size-of-root-partition.db’||The “root” partition is very critical to the Linux operating system .Read the file with crontab and get notified if the size exceed your predefined limit|
|watch ‘free |grep -i swap’||Check your swap space|
|watch ‘cat /proc/meminfo’||Continuously watch statistics for your system’s memory|
|watch who||Who is logged in your system . To focus on specific user , make use of grep|