Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CronExpressions - any librarys out there to generate them/convert them into human readable form?

I am using Quartz.NET, and my scheduler relies heavily on the use of cron expression's - such as the ones detailed on this link:

http://quartznet.sourceforge.net/tutorial/lesson_6.html

Ideally, I'd like the 2 scenarios to be made possible (the 1st is probably much difficult, and less likely to be anything out there for it)

1: The ability for the user to construct a cron expression on an ASP.NET form, where they choose which minutes, hours, days etc

2: The ability to turn a cron expression into a short string, such as 'Every {x} minutes on Friday' or 'At {x} o clock on the last day of every month'

I've begun writing my own versions of these, but it's a very hefty task and I'd love to find out there's a library out there, or even to have any hints and tips on this off you guys.

Note: If there is nothing out there for this and I am (relatively) successful in creating the code, I'll gladly share the source if anyone wants it.

like image 311
Chris Avatar asked Jun 23 '11 10:06

Chris


People also ask

What is cron expression generator?

A cron expression is a string consisting of six or seven subexpressions (fields) that describe individual details of the schedule. These fields, separated by white space, can contain any of the allowed values with various combinations of the allowed characters for that field.

What does 0 * * * * mean in crontab?

0 * * * * -this means the cron will run always when the minutes are 0 (so hourly) 0 1 * * * - this means the cron will run always at 1 o'clock. * 1 * * * - this means the cron will run each minute when the hour is 1.

How many types of cron are there?

Crontab (cron table) is a text file that specifies the schedule of cron jobs. There are two types of crontab files. The system-wide crontab files and individual user crontab files. Users' crontab files are named according to the user's name, and their location varies by operating systems.


1 Answers

I wrote a C# library that does just this. It's called cron-expression-descriptor. https://github.com/bradymholt/cron-expression-descriptor.

like image 97
Brady Holt Avatar answered Sep 22 '22 22:09

Brady Holt