Chris Thielen wrote:
> "Rules De Jour": An automated way to keep up with the latest rulesets.
> http://www.exit0.us/index.php/RulesDeJour

  # Get latest SpamAssassin rules. Runs at 4:28AM every day.
  28 4 * * *                                      /root/bin/rules_de_jour

If this script becomes popular then there will be an impulse spike on
the servers at that time (within each timezone) every day.  This has
been known to create problems in other similar cases.  Better to
randomize a delay to make sure that these do not all go off at once.

It is already a bash script so no problem with using something
non-POSIX.  The RANDOM variable came to bash by way of the Korn Shell
and is not POSIX standard and the ((..)) is not guarenteed in POSIX
either.  But the rest should run on any platform portably.

Test -t 0 means if file descriptor zero (standard input) is a tty
device.  This will be true interactively but false by cron.  Which
means if you just run it by hand on the command line then it executes
now with no delay.  But if run by cron then stdin is attached to
/dev/null and it will dither around within the timezone's hour that
cron runs this program and will prevent impulse spikes on the servers.

  MAXDELAY=3600
  if [ ! -t 0 -a $MAXDELAY -gt 0 ] ; then
     sleep $(($RANDOM % $MAXDELAY))
  fi

Bob

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to