A runwhen example

This example maintains a mirror of code.dogmap.org. in the directory ./mirror. It runs under supervise from D. J. Bernstein's daemontools package.

# cd /service/mirror-dogmap

# cat run
#!/bin/sh -e
exec 2>&1 \
setuidgid mirroruser                \
rw-add   n d1S             now1s    \
rw-match \$now1s ,H=2,M=30 wake     \
statfile -M finished                \
rw-add \$MTAI64N d36H      latest   \
rw-min \$wake \$latest     wake     \
statfile -M started                 \
rw-add \$MTAI64N d1H       earliest \
rw-max \$wake \$earliest   wake     \
sh -c '
  echo "@$wake" | tai64nlocal | sed "s/^/next run time: /"
  exec "$@"' arg0 \
rw-sleep \$wake                     \

# cat doit
#!/bin/sh -e
touch started
ftpcopy -x '/mirror/*' code.dogmap.org / ./mirror
touch finished