String #Scheduled trigged before the set time with long time pass - spring

I made a schedule by #Scheduled
#Scheduled(cron = "0 0 23 * * ?")
but the method trigged 9 PM or 10 PM everyday, it not only 1 second different, it for a long time
log:
2023-01-14 21:04:12,582 INFO c.e.t.b.d.c.DAGController [scheduling-1]
and different trigged time every day
the server runs on k8s
the pod date is correct, the server date is correct
Spring version : 5.1.6.RELEASE
add some infomation
1, #Scheduled used with #Async. There are three schedule task on 8AM, 10PM and 11PM, each one is finished quickly started early from logs. The first task after server starting started on wrong time
2, server and k8s pod use CST time, and time is correct. There is no rule for running time , the running time is different every day, and it is not a full point
3,restart pod ,restart server , repull image from harbor is useless
need help, thanks

Related

Cron job set up in local timezone gets incorrectly converted to UTC (using Serverless Local Schedule)

I have a schedule for job set up as follows using serverless-local-schedule:
- schedule:
rate: cron(1 0 20 * ? *)
timezone: Asia/Tokyo
It is supposed to run at 00:01 on the 20th day of each month. However, the schedule expression for the trigger that actually appears in AWS console looks like this:
cron(1 15 20 * ? *)
Time difference is calculated correctly (it's a 9-hour difference), but change of day is not taken into account - it should be:
cron(1 15 19 * ? *)
The job did run a day later than supposed to. What might be the cause of this issue?

NiFi || I have a requirement where i need to schedule a flow biweekly Monday & friday for every hour but in different timezone

I have to schedule a flow Bi-weekly for monday & friday for every hour.
0 11 * ? * 2,6
But the issue I am having is in timezone , i want the same in IST while it is running in UTC.
I guess there's an option to change timestamp in Bootstrap.conf file but i have many other flows which are running as per UTC scheduling.
Can anyone tell me any feasible solution as I am blocked.
#Ashu
This is a very edge type use case, when conflicting with other flows. Can you not determine the correct time in UTC?
Another idea I have used in the past: if you cannot control the flow in nifi, perhaps you can rethink the trigger method for starting the flow. For example: instead of start of flow from starting processor on cron, make the flow always on but started by trigger on existence of a file (List/fetch File). Then use a separate method outside of nifi to create that file at the time that you want. Now Nifi will only kick off the flow when the file exists.
You can schedule the job as 30 00 * ? * 2,6 , as per UTC Timezone.
which would run every 1 hour monday and friday.
2020-10-23 Fri 00:00:30
2020-10-23 Fri 01:00:30
2020-10-23 Fri 02:00:30
2020-10-23 Fri 03:00:30
2020-10-23 Fri 04:00:30
01AM UTC is 5:30AM IST, which will run your workflow from 5:30AM IST every hour

How can we schedule nifi data flow ? I'm using HDP 2.5

I want to schedule data flow in daily base through nifi.
For Example,
I need to run schedule on 9.00 AM in every morning.
Can anyone tell me what is procedure to make schedule data flow
There are three scheduling strategy available, see below details
Timer driven: This is the default mode. The Processor will be scheduled to run on a regular interval. The interval at which the Processor is run is defined by the ‘Run schedule’ option (see below).
Event driven: When this mode is selected, the Processor will be triggered to run by an event, and that event occurs when FlowFiles enter Connections feeding this Processor. This mode is currently considered experimental and is not supported by all Processors. When this mode is selected, the ‘Run schedule’ option is not configurable, as the Processor is not triggered to run periodically but as the result of an event. Additionally, this is the only mode for which the ‘Concurrent tasks’ option can be set to 0. In this case, the number of threads is limited only by the size of the Event-Driven Thread Pool that the administrator has configured.
CRON driven: When using the CRON driven scheduling mode, the Processor is scheduled to run periodically, similar to the Timer driven scheduling mode. However, the CRON driven mode provides significantly more flexibility at the expense of increasing the complexity of the configuration. The CRON driven scheduling value is a string of six required fields and one optional field, each separated by a space.
You typically specify values one of the following ways:
Number: Specify one or more valid value. You can enter more than one value using a comma-separated list.
Range: Specify a range using the - syntax.
Increment: Specify an increment using / syntax. For example, in the Minutes field, 0/15 indicates the minutes 0, 15, 30, and 45.
You should also be aware of several valid special characters:
* — Indicates that all values are valid for that field.
?  — Indicates that no specific value is specified. This special character is valid in the Days of Month and Days of Week field.
L  — You can append L to one of the Day of Week values, to specify the last occurrence of this day in the month. For example, 1L indicates the last Sunday of the month.
For example:
The string 0 0 13 * * ? indicates that you want to schedule the processor to run at 1:00 PM every day.
The string 0 20 14 ? * MON-FRI indicates that you want to schedule the processor to run at 2:20 PM every Monday through Friday.
The string 0 15 10 ? * 6L 2011-2017 indicates that you want to schedule the processor to run at 10:15 AM, on the last Friday of every month, between 2011 and 2017.
For your schedule time should be like below;
0109*?** - this meaning every 1 seconds 09 minutes is morning 9 AM other * fields run every day and month.
I hope it helps you!!!
Scheduling Strategy: CRON driven
Run Schedule: 0 0 9 * * ? *

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)

quartz spring cron trigger fire immediately

I have a spring application that uses quartz cron trigger. I have given the following for frequency 0 0/20 * * * ?.....once every 20 min. But i want the first one to run immediately. Right now, when I start the application, it runs after 20 min. I was hoping it would run asap and then after 20 min.
Thanks in advance.
It sounds like you want to use an interval trigger (SimpleTrigger in Quartz can do the job).
The CronTrigger wants you to specify the minutes at which to run.
So your trigger schedule says: start at 0 minutes, and run every 20 minutes after that until the hour is over. Then start at 0 again.
But with the SimpleTrigger, you say - start now and run every 20 minutes.
Here is a tutorial on SimpleTrigger:
http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-05
Here is a tutorial on CronTrigger:
http://quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
You don't need CRON expression (and Quartz at all!) to run given code every 20 minutes. Just use fixed rate (Spring built-in):
#Scheduled(fixedRate=20 * 60 * 1000)
That's it! By default first invocation happens immediately, second after 20 minutes. Since Spring 3.2 you can even say initialDelay=10000 to run for the first time after exactly 10 seconds.
If you really want to use Quartz, check out SimpleTrigger.

Resources