Thursday, June 21, 2012

Linux Shell Tips - watch

If you want to monitor some command execution in time like "tail -f" for files, probably your linux box have nice solution for you:

watch -n 1 'ls -l'

Where:
'-n 1' - time (in seconds) to refresh command output
'ls -l' - command to execute in interval above

When we add '-d' option (help: highlight changes between updates), watch inform Us what was changed between command executions.

Example for 'ls' command below:


watch --color -n 10 -d 'ls -la'

Output:



After change in directory structure watch informs us about changes:

1 comment:

javin paul said...

I have used watch command to find out how many rows are inserting in mysql database per second its good command but avoid using it on production box.

Thanks
Javin
10 tips how to work fast , efficient and quick in unix