Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron expression validator

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.

like image 842
disasterkid Avatar asked Oct 09 '14 18:10

disasterkid


1 Answers

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.

like image 167
Kraiss Avatar answered Sep 30 '22 11:09

Kraiss