Watching commands and files
Written by pH   
Monday, 04 January 2010 12:25

This tutorial should work properly on all Unix based OSes.

 

Watching commands:

If you need to keep an eye on a command whose output is changing, use the watch
command.

For example, to keep an eye on your load average:

 

$ watch ‘cat /proc/loadavg’

 

Every two seconds, watch runs the cat command again. Use Ctrl+c to quit. To
change the refresh rate to 10 seconds, type the following:

 

$ watch -n 10 ‘ls -l’

 

To highlight the difference between screen updates, type:

 

$ watch -d ‘ls -l’

 

Type Ctrl+c to exit the watch command.

 

Watching Files:

You can use the watch command to watch the size of a file. For example, to watch a large ISO file named mydownload.iso as it downloads, use the following command:

 

$ watch ‘ls –l mydownload.iso’

 

To watch the contents of a plain text file grow over time, you can use the tail com-
mand. For example, you can watch as messages are added to the /var/log/messages
file as follows:

 

$ tail -f /var/log/messages

 

Pressing Ctrl+c will exit from the tail command.

Comments (0)


Reddit! Del.icio.us! Mixx! Free and Open Source Software News Google! Facebook! Slashdot! StumbleUpon! TwitThis Joomla Free PHP
Last Updated on Monday, 04 January 2010 12:43
 

Open Source Guides Forum

Follow us on Twitter Follow us

Become a Fan Become a Fan

Bookmark and Share

We have 7 guests online