Multiple CRON schedules on NIFI processor - cron

I have a GetTableFetch processor I run every Monday and Tuesday using 0 0 10 ? * MON,TUE *. I would also like to run this processor on the first of every month if it doesn't end up falling on a Monday or Tuesday (i.e. 0 0 10 1 * ? *).
Can I combine these two in NIFI?
NIFI doesn't have error-checking in CRON schedules so I can populate whatever I'd like but it may or may not work. I was wondering if 0 0 10 ? * MON,TUE *, 0 0 10 1 * ? * or 0 0 10 ? * MON,TUE *; 0 0 10 1 * ? * would work?
Or do I have to do something more complex like duplicating the processor and using some sort of Wait/Notify setup in order to ensure that only 1 flowfile gets passed to the flow rather than 2? If so, how would I do this?

Related

To run in a time window until midnight

I have an AirFlow scheduler that I want to run at 13 until midnight from Monday to Saturday. I wrote an expression like this:
0 13-0 * * 1-6
While trying to validate this in crontab.guru for example I get an error since 0 is smaller than 13:
https://crontab.guru/
Does anyone know how can I write a valid cron-expression for this type of schedule?
If you would like to run your command at minute 00 from 13:00 onwards till midnight (inclusive) on all days except Sundays, then you have to play a trick. It is not possible to define the hour 24 in a crontab. You can define the hour 00, but a crontab of the form
0 0,13-23 * * 1-6
will run on Monday 00:00 and not on Sunday 00:00 which is what the OP really wants.
Here are two methods you can use:
Run two crontabs:
0 13-23 * * 1-6
0 0 * * 2-7
Run a single crontab a minute earlier:
59 12-23 * * 1-6
How about: 0 13-23 * * 1-6
“At minute 0 past every hour from 13 through 23 on every day-of-week from Monday through Saturday.”
Source: https://crontab.guru/#0_13-23___1-6

Quartz Cron expression :Run every 15 days ie twice in a month

I want to set the scheduler with a quartz cron expression which will trigger every 15 days ,for example 1st and 15th of every month.The 0 15 10 15 * ? is triggering only on 15th of every
month.
I have tested this and the following expression works fine
"0 0 0 1,15 * ?"
the 1,15 statement fires triggers on 1st and 15th of every month at 00:00 hours.
You can change the first three zeroes to fire them at a particular time you want.
the 1st zero -> seconds
the 2nd zero -> minutes
the 3rd zero -> hours
0 0 1,15 * *
“At 00:00 on day-of-month 1 and 15.”
0 0 1,15 1 *
“At 00:00 on day-of-month 1 and 15 in January.”
0 0 1,15 1 6
“At 00:00 on day-of-month 1 and 15 and on Saturday in January.”
The following also works fine, it executes your command on the 15th and the 30th at 02:00 AM of every month:
0 2 */15 * * <yourCommand>
You just need to append 1 with a comma to your expression at 'Day of Month' block.
Rest is fine !
0 15 10 1,15 * ?
This will schedule to run every 1st and 15th day of the month and 10:15 am.

How to run quartz scheduler everyday once at 3 PM

I tried below two:
CronSchedule("0 15 * * *")
CronSchedule("0 0 15 ? * MON-SUN")
Both triggers the process again after sometime.
Run Job is 3pm everyday. You use expression: 0 0 15 * * ?

execute crontab twice daily at 00h and 13:30

i want to execute a script twice daily at 00:00 and 13:30 so i write :
0,30 0,13 * * *
it seems wrong for me, because like this, the script will fire at 00:00 , 00:30 , 13:00 and 13:30. Any idea ?
Try this-: 00 01,13 * * *
it will run at 1 A.M and 1 P.M
You can't do what you want in one entry, since the two minute definitions will apply for both hour definitions (as you've identified).
The solution is (unfortunately) use two cron entries. One for 00:00 and one for 13:30.
An alternative is perhaps to execute one script at 00:00. That script would execute your original script, then wait 13.5 hours and then execute that script again. It would be easy to do via a simple sleep command, but I think it's unintuitive, and I'm not sure how cron manages such long running processes (what happens if you edit the crontab - does it kill a spawned job etc.)
You CAN NOT do that with cron on a single line.
You have to create 2 separate lines like so:
# Will run "YourCommand" at 00:00 every day of every months
#Min Hours D of the M Month D of the Week Command
0 0 * * * YourCommand
# Will run "YourCommand" at 13:30 every day of every months
30 13 * * * YourCommand
Or, as a single line, you can run a command every x hours, like so:
# Will run "YourCommand" every 12 hours
0 */12 * * * YourCommand
or
# Will run "YourCommand" at 1am and 1pm every day
0 1,13 * * * YourCommand arg1 arg2
Try this out: 0 6,18 * * *
it will run at minute 0 past hour 6 and 18
Or you can try it out on cronguru
try ...
00,30 00,13 * * * [ `date +%H%M` == 1330 ] || [ `date +%H%M` == 0000 ] && logger "its time"
Try this out:
0 1,13 * * *
What the above code means:
Cron will run at minute 0 past hour 1 and 13
Sharing a screenshot from crontab.guru
30 0,13 * * * somecommand.sh
This is just purely an example, but you will see that this is a cron entry that will run at 0:30AM and then 1:30PM (13 is 1 in military time). Just comma separate the hours, or comma separate whatever section of the cron.
try this,
0 10 9/12 ? * *
At second :00, at minute :10, every 12 hours starting at 09am, of every day
Try this, Only if you have the same minutes for each schedule. This will run your job twice a day at 1:00 & 13:00
0 1,13 * * *
You can try quickly more variations here: https://crontab.guru/

How to write a cron expression for quartz.net?

I need to run one application first Wednesday of every month at 4 AM.
Seconds - 0
Minutes - 0
Hours - 4
Day of Month - *
Month - [I dont know]
Day of Week - 4
Year -
This one should do: 0 0 4 ? 1/1 WED#1 *
You can build your own expressions using CronMaker
Thats the answer:-
0 0 4 ? * 4#1

Resources