Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

setting cron driven jobs in nifi

Solved Go to solution

setting cron driven jobs in nifi

New Contributor

Hi,

I wanted to setup a processor which needs to run from 2:00 to 3:00 AM (every 15 mins).

can you please let me know if this will work:

0 0/15 2-3 * * ?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: setting cron driven jobs in nifi

Super Guru

@Gillu Varghese

> NiFi uses quartz cron expression for your case use below expression to run processor

0 0/15 2 1/1 * ? *

runs at 2:00AM,2:15AM,2:30AM,2:45AM.

> If you want to run at 3:00 AM then we need to use another trigger processor to be scheduled separately with below cron expression.

0 0 3 1/1 * ? *

Refer to this link to create/validate quartz cron expressions and this for more details regarding cron scheduling in NiFi.

In addition we can also add minutes with comma seperators

59 0,15,30,45,59 2 1/1 * ? *

runs at 2:00:59AM,2:15:59AM,2:30:59AM,2:45:59AM,2:59:59AM.

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

8 REPLIES 8

Re: setting cron driven jobs in nifi

New Contributor

0 0/15 2-3 * * ?

Re: setting cron driven jobs in nifi

Super Guru

@Gillu Varghese

> NiFi uses quartz cron expression for your case use below expression to run processor

0 0/15 2 1/1 * ? *

runs at 2:00AM,2:15AM,2:30AM,2:45AM.

> If you want to run at 3:00 AM then we need to use another trigger processor to be scheduled separately with below cron expression.

0 0 3 1/1 * ? *

Refer to this link to create/validate quartz cron expressions and this for more details regarding cron scheduling in NiFi.

In addition we can also add minutes with comma seperators

59 0,15,30,45,59 2 1/1 * ? *

runs at 2:00:59AM,2:15:59AM,2:30:59AM,2:45:59AM,2:59:59AM.

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

Re: setting cron driven jobs in nifi

New Contributor

@Shu thanks for the quick reply..wanted to know what is the difference between 0 0/15 2-3 * * ? and 0 0/15 2-3 1/1 * ? *

Re: setting cron driven jobs in nifi

New Contributor

there are 2 asterix before ? in first exp and asterix between ?..symbol is not getting pasted here

Re: setting cron driven jobs in nifi

Super Guru

@Gillu Varghese

Quartz cron expression needs to be atleast 6 fileds and last field will be optional

0 0/15 2 ? * * //no specific value for day of month as we have scheduled at 2 AM so cron triggers starting at 2AM
0 0/15 2 1/1 ? //invalid as month field doesn’t allow ? in it.
0 0/15 2 1/1 * ? 
(or)
0 0/15 2 * * ? //start first day of the month and execute each 1 day at 2AM

In this case both expressions will be same.

Please refer to this awesome explanation regards to Quartz cron:

0 0 0/1 1/1 * ? *
| |  |   |  | | | 
| |  |   |  | | +-- Year              (range: 1970-2099)
| |  |   |  | +---- Day of the Week   (range: 1-7 or SUN-SAT)
| |  |   |  +------ Month of the Year (range: 0-11 or JAN-DEC)
| |  |   +--------- Day of the Month  (range: 1-31)
| |  +------------- Hour              (range: 0-23)
| +---------------- Minute            (range: 0-59)
+------------------ Second            (range: 0-59)

* (“all values”)

used to select all values within a field. For example, “” in the minute field means *“every minute”.

? (“no specific value”)

useful when you need to specify something in one of the two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a particular day of the month (say, the 10th), but don’t care what day of the week that happens to be, I would put “10” in the day-of-month field, and “?” in the day-of-week field.

/ used to specify increments.

For example: “0/15” in the seconds field means “the seconds 0, 15, 30, and 45”. And “5/15” in the seconds field means “the seconds 5, 20, 35, and 50”. You can also specify ‘/’ after the ‘’ character - in this case ‘’ is equivalent to having ‘0’ before the ‘/’. ‘1/3’ in the day-of-month field means “fire every 3 days starting on the first day of the month”.

To explain difference between ? and * in the expressions, first of all take a look at this table:

Field Name      Mandatory   Allowed Values      Allowed Special Characters
Seconds         YES         0-59                , - * /
Minutes         YES         0-59                , - * /
Hours           YES         0-23                , - * /
Day of month    YES         1-31                , - * ? / L W   //allowed '?'
Month           YES         1-12 or JAN-DEC     , - * /
Day of week     YES         1-7 or SUN-SAT      , - * ? / L #   //allowed '?'
Year            NO          empty, 1970-2099    , - * /

Re: setting cron driven jobs in nifi

New Contributor

@Shu As you have said above instead of having two triggers,cant have a single one as 0 0/15 2-3 1/1 * ? * which would run from 2am to 3am

Re: setting cron driven jobs in nifi

New Contributor

@Shu cron.png

Re: setting cron driven jobs in nifi

Super Guru
@Gillu Varghese

Both cron triggers in the screenshot are same you can use either of them for scheduling purpose.

We cannot trigger just at 3AM, the largest time that we can trigger is at 2:59:59AM with one cron expression.