Unix Technical Forum

QUESTION: Looking for tools to read cron files and produce a calendar

This is a discussion on QUESTION: Looking for tools to read cron files and produce a calendar within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hey, all. So my cron is fairly long. And I don't make a point of memorizing it. So if ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 09:48 AM
BD
 
Posts: n/a
Default QUESTION: Looking for tools to read cron files and produce a calendar

Hey, all.

So my cron is fairly long. And I don't make a point of memorizing it.
So if I want to add a new job, and ensure that it doesn't collide with
another job, I have to manually review the cron, think about it, find
an appropriate time, etc.

You'd think that since a cron file is a standard format, that some tool
would exist to read a cron file and populate a graphical calendar of
some sort, to produce something that's at least _kind_ of intuitive.

Does such a thing exist??

Hope so...

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 09:49 AM
Mark Taylor
 
Posts: n/a
Default Re: QUESTION: Looking for tools to read cron files and produce a calendar

not sure about a calendar, but both websm and webmin have crontab pages
that make reading the crontab a little easier ..

my 2 cents anyhoo

Rgds
Mark Taylor

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 09:49 AM
takarov2003@yahoo.com
 
Posts: n/a
Default Re: QUESTION: Looking for tools to read cron files and produce a calendar

BD wrote:
> Hey, all.
>
> So my cron is fairly long. And I don't make a point of memorizing it.
> So if I want to add a new job, and ensure that it doesn't collide with
> another job, I have to manually review the cron, think about it, find
> an appropriate time, etc.
>
> You'd think that since a cron file is a standard format, that some tool
> would exist to read a cron file and populate a graphical calendar of
> some sort, to produce something that's at least _kind_ of intuitive.
>
> Does such a thing exist??
>
> Hope so...


The following (poorly written) perl script does something like that:

#!/usr/bin/perl -w

if (@ARGV == 1)
{
open (CTF, "$ARGV[0]") or die "Cannot open crontab for $ARGV[0]:$!";
@lines = <CTF>;

foreach $line (@lines)
{
if (index($line, '#') != 0)
{
chomp $line;
(@fields) = split /\s+/,$line ;
if ($fields[3] eq '*')
{
$months='1';
for ($lcnt=2;$lcnt<13;$lcnt++)
{
$months .= ",$lcnt";
}
} else {
$months=$fields[3];
}
if ($fields[2] eq '*')
{
$days='1';
for ($lcnt=2;$lcnt<31;$lcnt++)
{
$days .= ",$lcnt";
}
} else {
$days=$fields[2];
}
if ($fields[1] eq '*')
{
$hours='0';
for ($lcnt=1;$lcnt<24;$lcnt++)
{
$hours .= ",$lcnt";
}
} else {
$hours=$fields[1];
}
if ($fields[0] eq '*')
{
$mins='0';
for ($lcnt=1;$lcnt<60;$lcnt++)
{
$mins .= ",$lcnt";
}
} else {
$mins=$fields[0];
}
$cmd = $fields[5];
$cmd .= ' ' . $fields[6] if defined $fields[6];
$cmd .= ' ' . $fields[7] if defined $fields[7];
$cmd .= ' ' . $fields[8] if defined $fields[8];
$cmd .= ' ' . $fields[9] if defined $fields[9];
$cmd .= ' ' . $fields[10] if defined $fields[10];
$cmd .= ' ' . $fields[11] if defined $fields[11];
(@mons) = split /,/,$months;
foreach $mon (@mons)
{
(@doms) = split /,/,$days;
foreach $dom (@doms)
{
(@hrs) = split /,/,$hours;
foreach $hr (@hrs)
{
(@mns) = split /,/,$mins;
foreach $mn (@mns)
{
$hkey = sprintf "%02d%02d%02d%02d",$mon, $dom, $hr,
$mn;
# print $hkey, ' ', $cmd, "\n";


if (exists $event{$hkey})
{
$event{$hkey} .= "\n" . $cmd;
} else {
$event{$hkey} = "\n" . $cmd;
}
}
}
}
}
}
}
# sort the hash by the key and print it
@m= ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec');
@keys = sort { $a cmp $b } keys %event;
foreach $key (@keys)
{
printf "\n\n%s %s \@ %s:%s >> \n%s\n", $m[substr($key,0,2)-1],
substr($key,2,2), substr($key,4,2), substr($key,6,2), $event{$key};
}
} else
{
print "You must specify a crontab file\n";
}

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-05-2008, 09:49 AM
BD
 
Posts: n/a
Default Re: QUESTION: Looking for tools to read cron files and produce a calendar

> The following (poorly written) perl script does something like that:

Oh, thanks! I'll see what I can make of it.

I'm still in elementary school as far as scripting is concerned, or I'd
have taken something like that on myself. ;-)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:18 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com