tags:

views:

189

answers:

2

Hi All,

I have a few little scripts that I use for monitoring some aspects of our application that reside in an infinite loop with a 3 second sleep and simply display the output of ps aux | grep -i app_name or mysql -e "SHOW SLAVE STATUS\G" just so I can easily watch for a few mins without hitting any keys, what I'd like to know is how I could 'refresh' the values on the screen instead of appending to them, I guess the best example I have is of top, it refreshes values instead of continuously printing to the screen.

Any help would be extremely appreciated.

Thanks

+1  A: 

you can include the "clear" command in your loop (without looking at your code)

ghostdog74
Argh, so easy! Works beautifully, thanks! (I feel so silly!) :)
Christian
but it would clear the entire screen.. isn't there a way to delete a line on stdout just like using \b in C
Neeraj
+4  A: 

Try watch utility. It runs arbitrary command in configurable interval (-n flag). It also can highlight differences in output between refreshes (-d flag).

dimba
Great work. watch is very cool, never knew about it before. Thanks!
Christian