How to trigger a cronjob at specific time in hybris

1/17/2020

I want to trigger a cronjob at below timings every day 9 a.m. EST, 1 p.m. EST, 10 p.m. EST

Also do we have any other option than cron expression so that client can change this timing easily?

Regards, Rasika

-- user3809154
cron
hybris
kubernetes-cronjob

2 Answers

1/17/2020

Define "easily"! :D

Instead of cronexpression, in Impex you can do such:

INSERT_UPDATE Trigger; cronJob(code)[unique = true]  ; second; minute; hour; day; month; year; relative; active         ; maxAcceptableDelay
                 ; $siteUid-CartRemovalJob       ; 0     ; 5     ; 4   ; -1 ; -1   ; -1  ; false   ; true; -1

But I use cronexpressions...

To be honest, I would say that there can not be an easier language with same expression scale.

Maybe show your customer this: http://www.cronmaker.com/

-- Michael Wölm
Source: StackOverflow

1/19/2020

You need to create three triggers as follows:

INSERT_UPDATE Trigger; cronjob(code)[unique=true]; cronExpression[unique=true]
;your-cronjob-code; 0 0 9 1/1 * ? *
;your-cronjob-code; 0 0 13 1/1 * ? *
;your-cronjob-code; 0 0 22 1/1 * ? *

Note that Hybris Cron Job uses Quartz library and you can learn more about cron expressions at http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html

There are some good websites which help you to create cron expression easily:

  1. http://www.cronmaker.com/
  2. https://www.freeformatter.com/cron-expression-generator-quartz.html

Also do we have any other option than cron expression so that client can change this timing easily?

The Hybris backoffice application provides a UI for the business users to create a trigger without using an ImpEx but unfortunately, it too requires a cron expression.

enter image description here

The earlier tool, hMC (shown below) used to provide a nice UI for business users to create a trigger without using a cron expression.

enter image description here

-- Arvind Kumar Avinash
Source: StackOverflow