On Wed, Jan 5, 2011 at 7:00 AM, Thomas Mueller <tho...@chaschperli.ch>wrote:

> Am Wed, 05 Jan 2011 04:59:29 -0800 schrieb Rune Stensø:
>
> > For something that's a bit more generic, you can also just use $RANDOM
> > with sleep. $RANDOM returns between 0 and 32k as a value, and you can
> > use a divider to reduce it.
> > For example, I use 'sleep $(($RANDOM/10)) && do_heavy_stuff' to
> > randomize the start of a heavy job out across just under a hour.
> >
>
> $RANDOM is "bash'ism". it's not available to all shells out there.
>
>
Right.  And if you do this:

#! /bin/bash
sleep $((RANDOM % 600))
exec puppet ...

Using modulus rather than division is probably better here.  This sleeps
somewhere from zero to 10 minutes.

Note also, you don't need to use $RANDOM inside $(()) in bash.

-- 
Jeff McCune
http://www.puppetlabs.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to