From a5383d98dbf506286d55d75aa7c04f0d98440691 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 29 Sep 2021 04:51:37 -0700 Subject: [PATCH] rewrite minutemaid documentation --- sh/minutemaid | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/sh/minutemaid b/sh/minutemaid index 0da6372..5be0f7a 100755 --- a/sh/minutemaid +++ b/sh/minutemaid @@ -5,15 +5,29 @@ # YES_ASH minutemaid() { ### @- - ### return 0 and/or execute a command if the current minute - ### is divisible by a given number. note that a minute is - ### relative to the seconds since the epoch, not the minute of the hour. - ### this ensures that commands will run roughly every N minutes, - ### regardless of the minute hand on the clock. + ### check if the current minute is divisible by a given number, + ### and optionally execute a command if it is. if a command is given, + ### either execute the command and return its exit value, + ### or execute nothing and return 0. if a command is omitted, + ### either return 0 on the minute, or return 1. + ### + ### note that a "minute" is relative to the seconds since the epoch, + ### not the minute of the hour. this ensures that commands will run + ### roughly every N minutes, regardless of the minute hand on the clock. + ### + ### note that `minutemaid 1` will always return 0, + ### and `minutemaid 1 command` will always execute the command, + ### since every integer "minute" is evenly divisible by 1. ### ### ``` ### # crontab usage: ### * * * * * minutemaid 9 ~/work/do_my_bidding # runs every nine minutes + ### # loop usage: + ### until minutemaid 9; do sleep 5; done + ### echo the wait is finally over; date + ### # improper usage: + ### while minutemaid 1; do sleep 1; done + ### echo this will never happen ### ``` local offset=0 name