What does the expression cron mean?

i has the expression cron.

"0 0 0 ? * SUN" 

when exactly is this done? midnight sunday saturday?

Thanks!

+6
source share
3 answers

See tutorial

 * * * * * * (year optional) ┬ ┬ ┬ ┬ ┬ ┬ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ └───── day of week (0 - 7) (0 or 7 is Sun, or use names) β”‚ β”‚ β”‚ β”‚ └────────── month (1 - 12) β”‚ β”‚ β”‚ └─────────────── day of month (1 - 31) β”‚ β”‚ └──────────────────── hour (0 - 23) β”‚ └───────────────────────── min (0 - 59) └───────────────────────── seconds 

Wild cards (symbol *) can be used to say "every" possible value to this field. Therefore, the * symbol in the "Month" field of the previous example simply means "every month." Therefore, the "*" field in the "Day of the week" field means "every day of the week."

"?" the symbol is allowed for the fields of the day of the month and day of the week. It is used to indicate "no special meaning." This is useful when you need to specify something in one of two fields, but not in the other. See the Examples below (and the CronTrigger JavaDoc) for more details.

So that means every Sunday at midnight

+22
source

This is actually not a cron expression. This expression is in the form of quartz.

http://quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/crontrigger

0 0 0 means midnight (second, minute, hour)

? means that it depends on other fields.

* means all months.

SUN means Sunday.

+3
source

The trigger fires at 00:00:00 AM every Sunday (morning). 0 is the beginning of the day, not the end. So next Saturday he will launch 23:59:59 on Saturday.

+1
source

Source: https://habr.com/ru/post/908149/


All Articles