[rescue] Speaking of backups, scripting division

Tim H. lists at pellucidar.net
Sun Nov 10 12:57:11 CST 2002


On Sun, 10 Nov 2002 16:52:55 -0500
"Sheldon T. Hall" <shel at cmhcsys.com> wrote:


> I was rather unclear in my previous reply.  I want to turn the first 5
> fields into a human-readable, unique date so I can put the resulting
> line of text on a status report, or put it in the body of an e-mail.
> 
> Although comments in the crontab are good, and I have plenty of them,
> they don't give me the ability to determine dynamically the date and
> time of the next activity of interest.
> 
> I want to be able to do this ...
> 
> echo "The next $activity is scheduled for `crontab -l | grep $activity
> |
> some_process`"
> 
> and get something anyone can read and understand, something I can
> include on the system's status report, or put in the body of an
> e-mail, or use in other ways that really have nothing to do with
> crontab.
> 
> What I lack is the program some_process, and I'm hoping someone here
> can point me to the standard way of doing that.
> 
> Thanks, though.
> 
> -Shel
> _______________________________________________
> rescue list - http://www.sunhelp.org/mailman/listinfo/rescue

The concept is simple enough, but cron accepts enough different ways to
say stuff that parsing it fully is going to be tough.  for instance:

*/5 in the minute field

is the same as 

0,5,10,15,20,25,30,35,40,45,50,55

and days of week and month can be text or numbers IIRC.

The one good thing is all fields are always required, so you can at
least chop it up prior to parsing with positional variables.  

filter the file through sed to remove comments, then chew it up with
your favorite mangling tool, perl or whatever.
 
I personally would probably do the whole thing with PHP, and serve a
page from the machine with a neat layout of the cron schedule for the
next 24 hours or whatever. I dopn't like extra administrative email
piling up.  hmmm, that actually might be a useful project....

Tim



More information about the rescue mailing list