cancel
Showing results for 
Search instead for 
Did you mean: 

how to create cronjob trigger except few minutes in every hour

Former Member
0 Kudos
1,565

Hi,

I need to create a cronjob trigger to run every 15 minutes. But i would like to exclude the cronjob not to run between 11 AM - 11.29 AM & 9 PM - 9.29 PM.

INSERT_UPDATE Trigger;cronjob(code)[unique=true];cronExpression #% afterEach: impex.getLastImportedItem().setActivationTime(new Date()); ;myJobName; 0 0/15 * ?

I know that this will run for every 15 minutes. But how do i specify the exclusions? Please help.

Thanks Vidhya

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Thank you all for the help. Yes it requires 2 triggers. I did add them and it works fine

Former Member
0 Kudos

Create two triggers for the cron job as like below,

0 0/15 0-11,12-21,22-23 * * ?

0 30-45/15 11,21 * * ?

VinayKumarS
Active Contributor
0 Kudos

Hi Vidya,

You can use cron expression instead of creating two triggers. This expression will work

 0 0/15 0-11,12-21,22-23 * * ?
tsang
Explorer
0 Kudos

Hi Vinay, this is only partly correct.

Keep in mind that this solution only provides a trigger for FULL hours. Therefore it wold not exclude the mentioned time from Vidya.

Nevertheless if the additional off time can be excepted I would agree that this is a valid solution.

andyfletcher
Active Contributor
0 Kudos

Isn't this the same as

 0 0/15 * * * ?

?

Wouldn't you want 2 expressions

 0 0/15 0-10,12-20,22-23 * * ?
 0 30,45 11,21 * * ?

(as Konstantin has pointed out)

tsang
Explorer
0 Kudos

The simpliest way to run the task behind the specific cronjob would be in your case to create 2 cronjobs which will be started between 9.30 PM - 11-AM and another one between 11.30 to 9PM.

Otherwise it is more complicated because the configuration within hybris standard is limited in this scenario.