Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to prevent spring batch job from running on particular day?

0 0 0 25 12 ?

this cron expression runs on every Christmas Day at midnight. I want to prevent it from running on Christmas Day.

like image 819
Sonal Avatar asked Dec 06 '25 05:12

Sonal


1 Answers

since you can define cron expressions only when they should run and not when they shouldn't run, i see only two options here:

  1. check the current Date within your task/job and if its Christmas Day, skip execution
  2. define a / multiple cron(s) that run on every other day than Christmas
    #runs every day starting january till november
    0 0 * * 1-11 *
    #runs every day in december except at the 25th
    0 0 * 1-24,26-31 12 *
like image 112
BadK Avatar answered Dec 08 '25 17:12

BadK