]> git.netwichtig.de Git - user/henk/code/snooze.git/blobdiff - README.md
typo
[user/henk/code/snooze.git] / README.md
index 7b1bd20f3ab81ffeafda5372f9aef2a615f9891d..7449a140a57404497e9fea852989b6e451e6aa4c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
 ## snooze: run a command at a particular time
 
-`snooze` is a new tool for to wait until a particular time and then
-run a command.  Together with a service supervision system such as runit,
-this can be used to replace cron(8).
+`snooze` is a new tool for waiting until a particular time and then
+running a command.  Together with a service supervision system such as
+runit, this can be used to replace cron(8).
 
-`lr` has been tested on Linux 4.2.
+`snooze` has been tested on Linux 4.2.
 It will likely work on other Unix-like systems with C99.
 
 ## Benefits
@@ -23,6 +23,7 @@ Over cron:
   runs, even across reboots
 - randomized delays (some cron have that)
 - variable slack (no need for anacron)
+- ad-hoc usage possible, just run the program from command line
 
 Over runwhen:
 - less confusing usage (I hope)
@@ -31,6 +32,7 @@ Over runwhen:
 
 Over uschedule:
 - due to supervision, no centralized daemon required
+- filtering by ISO week and day of year
 
 ## Rosetta stone
 
@@ -61,6 +63,9 @@ Over uschedule:
 * `-R`: add between 0 and RANDDELAY seconds to the scheduled time.
 * `-s`: commands are executed even if they are SLACK (default: 60) seconds late.
 
+The durations RANDDELAY and SLACK and TIMEWAIT are parsed as seconds,
+unless a postfix of `m` for minutes, `h` for hours, or `d` for days is used.
+
 The remaining arguments are patterns for the time fields:
 
 * `-d`: day of month
@@ -99,7 +104,7 @@ of TIMEFILE plus TIMEWAIT seconds.
 
 When `-T` is *not* passed, snooze will start finding the first matching time
 starting from the mtime of TIMEFILE, and taking SLACK into account.
-(E.g. `-H0 -s$((24*60*60)) -t timefile` will start an instant
+(E.g. `-H0 -s 1d -t timefile` will start an instant
 execution when timefile has not been touched today, whereas without `-t`
 this would always wait until next midnight.)
 
@@ -136,15 +141,15 @@ Run a job like cron, every day at 7am and 7pm:
 
 Run a job daily, never twice a day:
 
-       exec snooze -H0 -s $((24*60*60)) -t timefile \
+       exec snooze -H0 -s 1d -t timefile \
                sh -c 'run-parts /etc/cron.daily; touch timefile'
 
 Use snooze inline, run a mirror script every hour at 30 minutes past,
 but ensure there are at least 20 minutes in between.
 
        set -e
-       snooze -H'*' -M30 -t timefile -T $((20*60))
-       touch timefile  # remove this if instantly retrying on failure is ok
+       snooze -H'*' -M30 -t timefile -T 20m
+       touch timefile  # remove this if instantly retrying on failure were ok
        mirrorallthethings
        touch timefile
 
@@ -155,6 +160,16 @@ Use snooze inline, cron-style mail:
        actualjob >output 2>&1 ||
                mail -s "$(hostname): snooze job failed with status $?" root <output
 
+Snooze for rate-limiting a general purpose runit service: don't
+restart faster than every two minutes. (Note that after a crash with a
+daemon runtime of more than two minutes, it will be restarted
+immediately):
+
+       set -e
+       snooze -H'*' -M'*' -S'*' -t timefile -T 2m
+       touch timefile
+       exec mydaemond
+
 ## Installation
 
 Use `make all` to build, `make install` to install relative to `PREFIX`