54

I installed Cygwin on my Windows XP to use some of its commands. Now I what to check a file every 2 minutes and want to use watch for this purpose but I see that Cygwin has no such command. Is this really true? what can I do instead?

  • 3
    You can find out which Cygwin packages provide which files and programs at cygwin.com/packages – Mikel May 18 '12 at 15:26
71

There is watch in cygwin. But it isn't installed by default. You need to install procps-ng package to appear watch. (you can run cygwin installer again and it allows to install only the missed packages without reinstalling the whole cygwin)

Instead of watch you can use simple cycle like:

while true ; do check file ; sleep 2 ; done

where check is your command of choice.

  • Is 'check' a command, or are you including it as a placeholder? I literally pasted this and I just got a sequence of -bash: check: command not found. The cygwin installer doesn't seem to know anything about it ... – robert Aug 20 '14 at 8:04
  • @robert, it is a placeholder. – rush Aug 20 '14 at 19:20
27

watch is in procps-ng, so install 'procps-ng' package.

  • That's exactly the package you need. Thx. – zero0 Jul 13 '14 at 15:05
8

Apparently procps is outdated, watch can now be found in the procps-ng package.

4

Installed the ncurses package and then I get a clear screen on every run. Thank you rush.

I ran mine as

while true ; do clear; <command> <file> ; sleep 2 ; done

such as

while true ; do clear; grep ERROR server.log | tail -n 5 ; done
1

I wrote a command that emulates watch. I released it with source and compiled .exe file. You can find it here: http://www.garrettgalloway.com/index.php?p=projects&e=7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.