Cron expression validator

11,092

Solution 1

UNIX Cron expressions and Quartz ones are differents. Simply,

  • In Unix
    • (minute, hour, day, month, day_of_week, year)
  • In Quartz
    • (second, minute, hour, day, month, day_of_week, year)

You can use this to know if a Cron expression is correct.

EDIT : Look at CronExpression.ValidateExpression method.

Solution 2

The question is aged but now there are more options.

I found useful this new nuget package NCrontab.Advanced that is a good replacement for the older NCrontab adding more features, and should have a more wide range of application.

Share:
11,092
disasterkid
Author by

disasterkid

Updated on June 08, 2022

Comments

  • disasterkid
    disasterkid almost 2 years

    I would like to have user-defined cron expressions in my program. Are there are validators for cron expressions so that the user cannot insert an invalid cron code?

    N.B. I think the cron expression on Quartz.Net has a slight different format than the one used in UNIX. I would like to the Quartz version of it.