The script runmaint is a wrapper for cronjobs (and in principle other batch jobs) which:
0 0 * * * exec /usr/local/script/runmaint dailyAnother common example is hourly maintenance such as running regular reports. This would imply a line like:
0 * * * * exec /usr/local/script/runmaint hourlyBoth of these imply their less frequent jobs (daily, monthly, etc); those jobs are checked for based on the noted frequency of the base job. An hourly job will, at midnight, run daily jobs, a daily job on Monday will run weekly jobs, a daily job on the first of the month will run monthly jobs, a daily job on the first of January will run yearly jobs.
Further, the less frequent jobs are run
after the more frequent jobs,
so you are guarrenteed that an unusually long
daily job will not overrun the weekly tidyup which expects it to have
finished, and that the weekly tidyup will run immediately after
the daily job rather than some guestimated "suffient time later".
You can see the implementation of this in the case
statement at the bottom of the script.
. /etc/profile.
. $HOME/.profile
| $RunMaint | The path of the runmaint command, for invocation of subsidiary scripts which are expected to have their output (if any) delivered in separate email. |
| $MaintScripts | The path of the maintenance scripts directory. |
| $MaintDir | The path of the maintenance directory (one up from $MaintScripts for root, the same as $MaintScripts for other users). Normally you will want to use $MaintScripts but perhaps you will want to keep associated data files which aren't themselves scripts separate. |
| $datestr and $wday, $mon, $mday, $hh, $mm, $ss, $tz, $year | $datestr is the output of the date
command at the time of starting runmmaint;
this The $wday, $mon, $mday, $hh, $mm, $ss, $tz and $year values are simply the broken out fields from this string. For example, the easy way to run something at 9am (as I do, to prefetch the web pages I read as daily news) is to examine $hh. Here's relevant code from my hourly script:
|
runmaint [-x] [-s subj] script [addresses...]-x turns on some execution tracing.
-s subj deliverys the output in email with the subject line subj instead of the default "runmaint@host script addresses".
addresses... is a space separated list of email addresses to which to delivery the output email. If not supplied the email is delivered to the invoking user.
script is the name of the script to run. runmaint will look for the scripts $MaintScripts/script and then $MaintScripts/script.$HOST and then $MaintScripts/script.$HOST@$SYSTEMID where $HOST is the short hostname of the current host and where $SYSTEMID is a name for the notional administrative domain in which the host resides. For example, at home I have $SYSTEMID set to "home" and at my ISP it's "zip" (www.zip.com.au). For example, by creating a single file called hourly.sid I can thus leave an hourly invocation of "hourly" in my crontabs and have actions run only on the host sid.
Also, as noted briefly above, is the script is called "hourly" then at midnight runmaint will also look for a "daily" script. When running "daily", on Monday it looks for a "weekly". When running "daily", on the first of the month it looks for a "monthly". When running "monthly", on the first of January it looks for a "yearly".