Subject: Re: Implementing periodic.d
To: Bill Studenmund <wrstuden@NetBSD.org>
From: Jim Bernard <jbernard@mines.edu>
List: tech-userlevel
Date: 04/14/2004 07:49:49
On Tue, Apr 13, 2004 at 01:10:57PM -0700, Bill Studenmund wrote:
> So how about this for an idea. Rather than daily.conf, weekly.conf, etc.,
> why not add files to /etc/periodic.d (or whereever the scripts are) that
> indicate when it should run? Make them crontab fragments. Have them take
> the name scheme: foo and foo.cron.
> 
> Taking rebuild_locatedb as an example. We'd have 
> /etc/rebuild.d/rebuild_locatedb and /etc/rebuild.d/rebuild_locatedb.cron. 
> The former is the script, and the latter would contain when the script 
> should run.
> 
> The .cron lines would be just like crontab entries, except the command 
> (well /bin/sh /etc/periodic.d/foo) would be implicit. Anything where the 
> command would normally be would be taken as command arguements or building 
> up a pipe.
> 
> All cron would need to do is learn to turn /etc/periodic.d/*cron files 
> into crontab entries for the respective files.

  One problem with a standard cron approach is that you would have to specify
in advance when to run each script.  In many cases you don't want your
machine to be flooded with large tasks all at once, so you would have to
guess how long each script would take to complete, and that tends to be
both difficult to guess and variable.  So, if cron is to be used, it would
be nice to have it somehow arrange for these special tasks to run sequentially
(or maybe with some limited parallelism on MP machines, though for many of
the tasks the bottleneck is disk IO), rather than having each task scheduled
at a prespecified time.

--Jim