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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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... |
| |||
| 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"; } |
| ||||
| > 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. ;-) |
| Thread Tools | |
| Display Modes | |
|
|