cmd

Executing a command in a loop with a delay

This command executes a command in a loop with the specified delay. Useful for instance if you want to monitor the status of your machine (disk space, network status…)

$ watch -n 4 du -ch .

The command above, executes “du -ch .” every four seconds.

Note: That’s a GNU command. Under FreeBSD watch is a completely different program. In order to use the GNU watch command, you have to install the gnu-watch package.

Note 2: If you don’t like watch you can always do something like this:

$ while true; do command; sleep delay; done

but watch is shorter XD

2 Comments

  • On 05.24.08 Pedro said:

    Well, I’d rather use

    # watch -n 4 du -cs .

    which just outputs the grand total (enough to know whether something has changed or not).

  • On 04.19.09 commandliners » iostat (BSD) said:

    [...] how many times you wan to update the information you want displayed. I find iostat more useful with gnu-watch Enjoy! Tagged: bsd, iostat, [...]

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*Required Fields