kakyo
kakyo

Reputation: 11590

cygwin: timeout syntax always fails

With Cygwin, I tried to use "timeout" to make my script sleep for a few seconds. But even when I did it according to its syntax it always asks me to try --help, meaning I gave the wrong forms. Here are the things I've tried

timeout 5

timeout 5s

timeout 5.0s

timeout 5.

None of which worked.

Any ideas?!

Upvotes: 1

Views: 1510

Answers (1)

Carl Norum
Carl Norum

Reputation: 224904

I don't think timeout does what you think it does. From the man page:

timeout [OPTION] NUMBER[SUFFIX] COMMAND [ARG]...

Start COMMAND, and kill it if still running after NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days.

You need to give it that command. Here's a simple example:

$ date; timeout 5 sleep 10; date
Thu, Nov 01, 2012  3:19:28 PM
Thu, Nov 01, 2012  3:19:33 PM

As you can see, only 5 seconds elapsed even though I ran sleep 10. That's because it timed out after 5 seconds and the timeout command killed it.

Upvotes: 6

Related Questions