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

These Might Interest You

  • The ebay URL is the search query copied from the browser (here searching for bed stuff). The regex is for crap that should not be shown. Important is "Pickup only", which filters away all the things that cannot be shipped (a filter that cannot be done on Ebay's webpage). It will output the title and url for all matching items, for all pages of the search result. It also works for the German Ebay. Show Sample Output


    0
    xidel --quiet 'http://www.ebay.com/sch/Beds-Bed-Frames-/175758/i.html?_from=R40&_sac=1&_sop=15&_nkw=bed' -e 'css(".lvresult")[not(matches(., "Pickup only|BUILDING PLANS \(ONLY\)|PARTS LIST"))]/css(".lvtitle")/(.||": "||a/@href)' -f 'css("a.gspr.next")'
    BeniBela · 2015-09-24 12:11:13 0
  • This command will place your card into monitor mode. Gets around the "ioctl(SIOCSIWMODE) failed: Device or resource busy" error encountered when running airodump-ng. Show Sample Output


    0
    iwconfig wlan0 mode monitor
    ozzy · 2011-11-04 02:36:42 0
  • Queries whether the monitor is on according to DPMS. If true then turns the monitor off, if false turns it on. The -display option on xset means the command will work from sessions other than the console, such as ssh or a cron'd script. Command should display any errors if there are any problems (eg no X available), otherwise no output if successful.


    0
    xset -display :0 q | grep ' Monitor is On' > /dev/null && xset -display :0 dpms force off || xset -display :0 dpms force on
    electrotux · 2015-04-06 19:04:04 0

  • 0
    ssh root@server 'tail --max-unchanged-stats=10 -n0 -F /var/log/auth.log ' | grep Accepted | while read l ; do kdialog --title "SSH monitor" --passivepopup "$l" 3; done
    skygreg · 2009-07-10 14:25:35 2

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: