Spring Cron expression to exclude running job on one day for set times - spring

I have a job that gets submitted every hour at 15 minutes past each hour via a Spring cron expression. A requirement has come up where this job is to not run at 12:15 am and 1:15 am on a Sunday morning.
My question is ... does cron support this kind of scenario where a job is to run every hour at 15 minutes past the hour except for 12:15 am and 1:15 am on a Sunday? Below is the expression that prevents it from running at 12:15 am and 1:15 am every day and it needs to be adjusted to only not run on Sunday at those times.
#Scheduled(cron = "0 15 2-23 * * ?")
Hopefully the above is clear. If not, please let me know and I will provide additional information.
Thank you in advance.

If it is wanted to run the job two specific days, it is possible to write the days together with comma.
Example: #Scheduled(cron = "0 15 2-23 * * SUN,MON)
Additionally, if you want to include all weekdays MON-FRI can be used:
Example: #Scheduled(cron = "0 15 2-23 * * MON-FRI)

Try
#Scheduled(cron = "0 15 2-23 * * SUN")

Related

Cron expression for a job that runs every 30 minutes in a specific time window

I have a job running in spring boot and I want to run it every 30 minutes between 12 AM and 8 AM starting at 12 AM. I am struggling to figure out the cron-expression that can be used to achieve this.
This is the cron you described: * 0/30 0-8 ? * *

Suggestions on setting cron from 11pm to 12am

Need help in setting cron from 11pm to 12am
===
* 22-23,23,0-1 * * *
===
but this seems to be not working; can we really set the cron in that time range as 24:00 is 00:00; its also fine to set it from 11pm to 11:59pm.
Thanks!
try "*/10 23,0 * * *" this should trigger at every 10th minute past hour 23 and 0.

CRON: Run job on particular hours

I have a spring batch application and i am using CRON to set how often this application runs. But the problem i am running into is that i want to run the job on specific hours
3 am
7 am
11 am
3 pm
7 pm
11 pm
As you can see it is every 4 hours but starts at 3 am so i cannot use */4 in the hours section of the timing format as this would start the job at 4am
I have also tried '3,7,11,15,19,23' in the hours section but this does not work either (guessing it only works in the minutes section). Does someone know how i can do this?
Use
#Scedule(cron="0 0 3/4 * * ?")
The Pattern x/y means: where <timepart> mod y = x
or
#Scedule(cron="0 0 3,7,11,15,19,21 * * ?")
According to the Quartz Cron Trigger Tutorial:
The '/' character can be used to specify increments to values. For
example, if you put '0/15' in the Minutes field, it means 'every 15th
minute of the hour, starting at minute zero'. If you used '3/20' in
the Minutes field, it would mean 'every 20th minute of the hour,
starting at minute three' - or in other words it is the same as
specifying '3,23,43' in the Minutes field. Note the subtlety that
"/35" does *not mean "every 35 minutes" - it mean "every 35th minute
of the hour, starting at minute zero" - or in other words the same as
specifying '0,35'.
0 0 3,7,11,15,19,23 * * ?
Fires for 0 minute starting at 3am and ending at 23:00 pm every day.
judging by the two answers above the error i was making was i was keeping the apostrophe at the start and end of my hours... very silly
i managed to solve this by using 3-23/4 for the hour as this starts from 3am and then every other fourth hour (just a different way of doing it to the other answers)

spring cronsequencegenerator pattern for job that run on 9th, 16th, 23th and 30th of every month at 10 O'clock.

I am struggling with the spring cronsequencegenerator pattern for job that run on 9th, 16th, 23th and 30th of every month at 10 O'clock.
Please help.
Spring provides a solution
Go through the documentation of Scheduled annotation and you be able to solve your problem.
Assuming it's 10AM and not 22:00 basic cron exp for you would be
0 10 9,16,23,30 * *
As per documentation cron-like exp is needed
0 0 10 9,16,23,30 * * - with additional first field for seconds.
Depending on specification (implementation) of "cron-like" your needs could suit
0 0 10 9,16,23,30 * ? - with day of the week special symbol
0 0 10 9,16,23,30 * * * - with optional field for year filled in

Cron for two times a day

I would like to schedule a cron job at 5am and 1830
I tried
0,30 5,18 * * *
but this actually run four times a day at
0500
0530
1800
1830
Can I set up cron to do this? I am using spring to run this cron job so if I cant do it using standard cron can I do it another way?
Thanks
You need to schedule it with two lines:
0 5 * * *
30 18 * * *
There is no way to specify some minutes/hours combination: if you define two couples of them, all combinations will be performed.

Resources