linux poison RSS
linux poison Email

Execute command at regular intervals

If you anytime need to execute a command once and again and again, you can use watch and tell it to execute the Linux command in a give interval.

The syntax of the command is:

watch [option(s)] command

The default interval of execution of the given command is two (2) seconds, but you define a different interval using the option -n.

Here are two useful uses of watch.

watch -n 5 free -m


Which will show you the use of memory each five seconds.

watch -n 30 vnstat -h


Which will show you the bandwidth used hourly, read more about vnstat.

You can also make watch to highlight any change it detect between two screens of output.

watch -n 30 -d vnstat -h


And if you want to maintain the highlight on, add =cummulative to the -d option, like this:

watch -n 30 -d=cummulative vnstat -h


[Ref: http://www.go2linux.org/repeat-command-continously-at-regular-interval-linux]


1 comments:

Anonymous said...

thanks a lot!!! i had forgot this command and it took me 15-20 minutes on google to ur post ;)

vishal

Post a Comment

Related Posts with Thumbnails