bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: feature request: sleep --random


From: Pádraig Brady
Subject: Re: feature request: sleep --random
Date: Fri, 18 Sep 2009 12:37:41 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Philip Rowlands wrote:
> This would help with some work I'm doing today, but is it of general
> interest?
> 
> $ sleep --random 4.0
> 
> sleeps for a random amount of time up to and including the requested
> value. The purpose is that on distributed systems it's disruptive to
> have synchronized scripts all starting up together. One option is to use
> the shell's $RANDOM if available, but it's lot of typing to get true (vs
> coarsely quantized) randomness.

Be careful with random sleeps:
http://www.stdlib.net/~colmmacc/2009/09/14/period-pain/

You're right that the existing is more verbose
but it's also more general:
sleep $(seq .1 .1 4 | head -n $(($RANDOM%40 +1)) | tail -n1)

I'm not sure we should add this.

cheers,
Pádraig.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]