Search code examples
validationcronquartz-scheduler

Is * * * * * ? a valid Cron Job?


I am talking about the Quartz scheduler having 6 values viz seconds,minutes,hours,day-of-month,month and day-of-week. The optional 7th field year is skipped. In that case, is this a valid cronjob? Is it supposed to run every second from initiated?

Second part of question: Is there any Cron validator available online? I have found some, but they are based on Linux Cron Jobs. I was looking for a Quartz Cron validator (Which is having an additional seconds parameter compared to Linux).


Solution

  • For every second use * * * * * ?.

    You can validate using Quartz CronExpression API. Just write a small Test using this method:

    org.quartz.CronExpression.isValidExpression(value);
    

    Hope it helps.