twzCronChart

twzCronChart is a PHP5 class that shows a simple Gantt chart of cron tasks

sample cron chart

The class parses the crontab to extract task and scheduling information. It also provides methods to retrieve the number of cron tasks, the cron line for each task, and the next or last date for any task.

To use it, simply instantiate the class and call the Chart() method:

$cron = new twzCronChart();
echo $cron->Chart();

Alternatively you can pass any crontab to the class, and set a few chart options such as date range and chart width:

$MyCron = file('../path/mycron.cron');
$cron = new twzCronChart($MyCron);
$cron->SetChartName('cron schedule');
echo $cron->Chart('now', '+week', 700);

twzCronChart could be used as the base for a more complex application that allows the user (site owner) to choose the options interactively.

 

twzCronChart
Version:

1.1.4

Licence:

freeware

Requires:

PHP5+

Filename:

twzCronChart-v1.1.4.zip

File date: 

2015-10-28


incinnerator
Comment
bug
Reply #1 on : Tue August 16, 2011, 22:25:41
*/15 * * * * can't be used.
error given: minute above maximum in line:

your class is also encrypted so I couldn't dig in to solve the problem, too bad
tony
Comment
Re: bug
Reply #2 on : Tue August 16, 2011, 23:01:38
Thanks for letting me know incinnerator. That bug is now fixed - please download twzCronChart again.
casper
Comment
bug
Reply #3 on : Mon January 16, 2012, 10:24:58
Same error for days:

day below minimum in line: 40 22 * * *
tony
Comment
Re: twzCronChart
Reply #4 on : Mon January 16, 2012, 10:39:51
Hi casper
That error will occur if there's an extra space after the hour part ("22"). Ensure there is only 1 space between each part in the cron line, and it should work ok.
casper
Comment
thx
Reply #5 on : Mon January 16, 2012, 10:48:54
Thanks for your fast reply. Now it's working :-D
casper
Comment
info
Reply #6 on : Mon January 16, 2012, 10:51:04
You should consider to replace (multiple) tabs and (multiple) spaces to a single space before processing the input. This would prevent such errors.
tony
Comment
Re: twzCronChart
Reply #7 on : Mon January 16, 2012, 10:53:26
Thanks for the suggestion - it's now on my to-do list!
casper
Comment
info
Reply #8 on : Mon January 16, 2012, 10:55:47
Sorry for spaming :) Another improvement would be to see the corresponding hours on top of the columns. I would support you by providing a patch, but unfortunatelly the source is a bit "messed up" :-P
tony
Comment
Re: info
Reply #9 on : Mon January 16, 2012, 11:09:11
You can see the date/time of any task by hovering your mouse over it. Headings are tricky to implement because the chart could be showing a single day, or a 6 month period, or even longer.

I'm intending to re-release this under a GPL at some stage (no immediate plans though).
oblus
Comment
comments?
Reply #10 on : Sun December 30, 2012, 03:07:42
what about # comments lines in crontab...
tony
Comment
comments?
Reply #11 on : Sun December 30, 2012, 12:21:44
Thanks oblus - v1.1.2 now ignores comment lines
matthieu
Comment
Problem with date format
Reply #12 on : Sat March 14, 2015, 00:31:47
Hello,

I have a problem with your class "twzCronChart". If I change date format and I fixed "FromDate" parameter to "13/03/2015 14:00", the code doesn't work (graph not displayed):

$cron->SetDateFormat('j/m/Y H:i');
echo $cron->Chart('13/03/2015 14:00', '+3 days', 750, 60); // 13 March 2015

But if the value is '12/03/2015' (12 March 2015), the result is '03/12/2015' (3 December 2015). Day and month appear reversed. An idea to fix the problem ?

> version 1.1.2 used.
tony
Comment
Re: Problem with date format
Reply #13 on : Sat March 14, 2015, 00:44:15
Hi matthieu

SetDateFormat() only sets the display format, not the format accepted by the Chart() $FromDate parameter.

I suggest you try calling Chart() with '13 Mar 2015 14:00' instead of '13/03/2015 14:00' and see how that goes.
Last Edit: March 14, 2015, 00:45:18 by tony  
Paolo
Comment
wishlist
Reply #14 on : Thu October 08, 2015, 19:18:00
Hi, great job overall; a nice improvement could be: drawing a red vertical line to mark current time (if start time < now - see above picture). Also the hour heading would be nice, as noted above.
tony
Comment
Re: wishlist
Reply #15 on : Wed October 28, 2015, 13:36:58
Hi Paolo
Thanks for your comment.
The latest version now supports date/time headings and a current time marker. There's also the possibility of setting an estimated duration for each task, which can be indicated on the chart.
Last Edit: October 28, 2015, 13:37:26 by tony  
Bruno
Comment
Re: twzCronChart
Reply #16 on : Wed October 28, 2015, 18:39:01
thanks Tony for this new version.
you provide a great support too, it's very cool!!

thanks a lot

Write a comment

  • Required fields are marked with *.