Joost Brugman is a freelance project manager and web developer based in Amsterdam, The Netherlands.

Joost is currently working on Streamline, an advanced web application framework in PHP and Javascript with extensive reusibility options. He is doing this while travelling around the world on a sabatical from Project Management.

He is also promotor for green energy, an avid supporter of microfinancing, a world traveller and he was the co-founder of "Improphecy", one of Amsterdam's premier improvised comedy shows but gave up performing himself in 2008 to persue other dreams.

Converting crontab entries to plain English

Or to any other language

Cron on UNIX certainly is a powerful tool for scheduling tasks. However, its configuration (the crontab entries) was certainly not designed to be pleasantly readable to humans. For the development of the StreamlineFoundation plugin I was looking for a way to convert any crontab entry into human readable form but I could not find anybody who had done it. So, I made it and here it is, with multilanguage support:

minuteshoursdays/monthmonthsdays/weekYears

Presently you can provide any standard cron specification which includes:

  • Fixed numbers: e.g. 10 to specify exactly 10.
  • Ranges: e.g. 10-50/5 to specify 10, 15, 20, 25, 30, 35, 40, 45, 50.
  • Lists: e.g. 3,10-20/5,9 to specify 3, 10, 15, 20 and 9.
  • Wildcard: * to specify the entire range

There is presently no support for the ? wildcard, but providing a * is equal to my knowledge even though strictly speaking * constitutes a value and ? constitutes NULL. I have omitted special characters such as L and W since I could find no documentation that was sufficiently specific and - besides - I could not find those characters in the UNIX man pages at all anyway.

The code behind this is packed in a PHP class that accepts a cron specification to set up a schedule. All you need to do then, is call the necessary function to get the cron specification in the natural language of your choice:

$cron = ns\Schedule::fromCronString('* * * * * *', 'en');
$cron->asNaturalLanguage();

It also has a couple of really nice features such as moving back and forth through the scheduled points in time by calling ->next() and ->previous(). These functions return a UNIX timestamp, an ISO formatted datetime string (YYYY-MM-DD HH:II:SS) or a 5-element array with the date and time components in integer format.

Keep an eye out. I expect to release the initial release of Streamline, and the StreamlineFoundation plugin, including this class, in spring 2012. If you wish to use it in the meantime, drop me a note.

Note: All articles on BITS OF THOUGHT assume that you use a DOCTYPE of HTML or XHTML and use an UTF-8 content encoding. If you don't you are - quite frankly - running behind schedule upgrading your website. You are at risk of compatibility problems.

BITS OF THOUGHT is (c) by Joost Brugman / privacy