RANDSLEEP(1) | General Commands Manual | RANDSLEEP(1) |
randsleep
—
randsleep |
time [command args ...] |
randsleep
version 0.0
randsleep
execs into command after
sleeping for up to time seconds. It is intended for use
in cronjobs and similar.
If command is not specified,
randsleep
will simply return after sleeping.
Since the snippets responsible for this may, especially if the
shell does not support $RANDOM
, become quite long, I
decided to write this utility. It is an extremely simple C program with no
additional dependencies, so using it should not be a problem.
#!/bin/sh
if [ -z "$RANDOM" ];
then
RANDOM=$(dd if=/dev/urandom count=1
2> /dev/null | cksum | cut -c"1-5")
fi
sleep $(( RANDOM % 1800
))
# actually do something
With randsleep
:
#!/bin/sh
randsleep 1800
# actually do something
Or (as crontab entry):
10 * * * * root randsleep 1800
/path/to/script with arguments
July 6, 2011 | Debian |