Continually monitor things

while (true); do clear; uname -n; echo ""; df -h /; echo ""; tail -5 /var/log/auth.log; echo ""; vmstat 1 5; sleep 15; done
You can use this one-liner for a quick and dirty (more customizable) alternative to the watch command. The keys to making this work: everything exists in an infinite loop; the loop starts with a clear; the loop ends with a sleep. Enter whatever you'd like to keep an eye on in the middle.
Sample Output
hostname

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             182G   32G  141G  19% /

Aug 22 23:17:01 hostname CRON[27580]: pam_unix(cron:session): session closed for user root
Aug 22 23:25:01 hostname CRON[27584]: pam_unix(cron:session): session opened for user root by (uid=0)
Aug 22 23:25:01 hostname CRON[27584]: pam_unix(cron:session): session closed for user root
Aug 22 23:35:01 hostname CRON[27768]: pam_unix(cron:session): session opened for user root by (uid=0)
Aug 22 23:35:01 hostname CRON[27768]: pam_unix(cron:session): session closed for user root

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0    428 1382640  70536 252300    0    0     7     3   10    3  0  1 99  0
 0  0    428 1382632  70536 252388    0    0     0     0  181  152  0  0 100  0
 0  0    428 1382632  70536 252388    0    0     0     0  171  129  0  0 100  0
 0  0    428 1382632  70536 252388    0    0     0     0  176  153  0  1 99  0
 0  0    428 1382632  70536 252388    0    0     0     0  163  128  0  0 100  0

1
By: roknir
2010-08-23 04:37:58

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: