CronJobService

The CronJobService is used for the timed starting of processes. The following options are provided to control the times at which a start is to take place.

  • Repeated start after a certain time interval, i.e. a start happens every 10 minutes (relative time)

  • Repeated start at certain times, e.g. every Monday at 13.00 o'clock (absolute time).

  • Single start at a certain time, e.g. on 27.01.2018 (absolute time).

  • One-time or repeated start using the crontab syntax.


Each process to be started must be provided as a Java class that implements the ITask interface in the package com.ebd.hub.services.cron.

XML configuration


Important note: The availability of a service depends on the license purchased and whether the service has been registered in the configuration file ./etc/factory.xml of the Service Factory (changes require server restart!). There you will also find the responsible configuration file for a service, otherwise you can also edit the configuration file of the service directly in the GUI of the service (changes require a service restart!).

Adding a cron job


The following XML fragment is needed to add a new cron job to the CronJobService.

<Call name="addJob">
<Arg>
<New class="com.ebd.hub.services.cron.CronJob">
<Arg>Cron_job_name</Arg>
<Arg>
<New class="Class_name_of_the_cron_job">
</New>
</Arg>
[time control settings]
</New>
</Arg>
</Call>


The first argument specifies the name of the cron job under which it should appear in the list, the second argument contains the class (implementing the ITask interface) to be executed by the CronJobService.

Depending on which type of timing is selected, the following XML portion differs. This will be described in the following.

Time interval controlled execution without scope

If the cron job is to be started repeatedly after a certain time has elapsed, the following XML fragment should be used.

<Call name="setTimeSchedule">
<Arg>
<New class="com.ebd.hub.services.cron.Schedule">
<Arg type="long">3600000</Arg>
</New>
</Arg>
</Call>


The number passed as an argument represents the time between two calls in milliseconds. In the given example, that is one hour.

Attention: When the server or service is started, the cron job is not executed immediately. Shutting down or stopping the server just before the cron job is executed may cause the time between two executions to be up to twice as long as you might expect.

Time interval controlled execution with scope


If the cron job is to be started repeatedly after a specific time has elapsed but restricted to a certain period of time, the following XML fragment should be used.

<Call name="setTimeSchedule">
<Arg>
<New class="com.ebd.hub.services.cron.Schedule">
<Arg type="long">3600000</Arg>
<Call name="setStart">
<Arg type="int">2003</Arg>
<Arg type="int">8</Arg>
<Arg type="int">23</Arg>
<Arg type="int">5</Arg>
<Arg type="int">0</Arg>
</Call>
<Call name="setStop">
<Arg type="int">2013</Arg>
<Arg type="int">8</Arg>
<Arg type="int">22</Arg>
<Arg type="int">17</Arg>
<Arg type="int">0</Arg>
</Call>
</New>
</Arg>
</Call>


The above example restricts the cron job to the time between 23.08.2003, 05.00 o'clock and 22.08.2013, 17.00 o'clock.

If only a start date or an end date is to be set, the respective other block (setStop or setStart) can simply be omitted.

Time-of-day controlled execution without scope


If the cron job should run every day at a certain time and from there on after a certain interval, this can be set with the following XML fragment.


<Call name="setTimeSchedule">
<Arg>
<New class="com.ebd.hub.services.cron.Schedule">
<Arg type="int">13</Arg>
<Arg type="int">31</Arg>
<Arg type="long">3600000</Arg>
</New>
</Arg>
</Call>


The example above starts the cron job at 13:31 o'clock and then every other hour.

Time-of-day controlled execution with scope


If you want to start the cron job every day at a specific time and from there after a certain interval but limited to a certain period of time, you can set this with the following XML fragment.


<Call name="setTimeSchedule">
<Arg>
<New class="com.ebd.hub.services.cron.Schedule">
<Arg type="int">13</Arg>
<Arg type="int">31</Arg>
<Arg type="long">3600000</Arg>
<Call name="setStart">
<Arg type="int">2003</Arg>
<Arg type="int">8</Arg>
<Arg type="int">23</Arg>
<Arg type="int">5</Arg>
<Arg type="int">0</Arg>
</Call>
<Call name="setStop">
<Arg type="int">2013</Arg>
<Arg type="int">8</Arg>
<Arg type="int">22</Arg>
<Arg type="int">17</Arg>
<Arg type="int">0</Arg>
</Call>
</New>
</Arg>
</Call>

Starting the cron job at exactly defined times (TimeTable)


If the cron job should only be started at specific times, this can be set with the following XML fragment.

<Call name="setTimeSchedule">
<Arg>
<New class="com.ebd.hub.services.cron.Schedule">
<Call name="addTimeTable">
<Arg>
<New class="com.ebd.hub.services.cron.TimeTable">
<Arg type="int">2018</Arg>
<Arg type="int">12</Arg>
<Arg type="int">31</Arg>
<Arg type="int">12</Arg>
<Arg type="int">0</Arg>
</New>
</Arg>
</Call>
</New>
</Arg>
</Call>


This example starts the cron job on 31.12.2018 at 12:00 o'clock (12 pm).

General settings


images/download/attachments/189461511/Services_28_EN-version-1-modificationdate-1737965340744-api-v2.png

images/download/thumbnails/189461511/Services_29_EN-version-1-modificationdate-1737965340741-api-v2.png


(1) Here the logging for the CronService can be configured. You can switch it on and off and set which LogService and which LogManager should receive the messages. By clicking on the Set button, the changes are applied.

(2) The list of available cron jobs. The status, the time of the last run and the time for the next run are displayed. Note: See section 'System Cronjobs' below.

(3) The context menu allows you to view, activate, start, remove and add a cron job. You can also explicitly enable verbose mode for a specific cron job (instead of activating it for the whole service).

Adding a cron job via the Admin Console


The admin console offers the possibility to add cron jobs. Attention: The cron jobs added in the Admin Console will be lost after a reboot. When starting the CronJobService, only the cron jobs configured in the XML file are added.


images/download/attachments/189461511/Services_51_EN-version-1-modificationdate-1737965340738-api-v2.png


(1) The name of the cron job.

(2) The name (with package) of the class that implements the interface ITask.

(3) The validity period of this cron job.


Following the different time setting options for cron jobs.


images/download/attachments/189461511/Services_52_EN-version-1-modificationdate-1737965340735-api-v2.png

images/download/attachments/189461511/Services_53_EN-version-1-modificationdate-1737965340732-api-v2.png

images/download/attachments/189461511/Services_54_EN-version-1-modificationdate-1737965340729-api-v2.png


(4) Here you can specify the time interval in seconds or minutes.

(5) Here an absolute time can be specified. The cron job will run once at the specified time.

(6) Here you can specify a relative time, e.g. every Monday at 00:00.

(7) You can use the context menu to create an entry in classic crontab syntax. For further information see section Crontab syntax.

Log level dependencies


Changes to the log level of the LogService may have an influence on the scope of log messages of the CronJobService. However, this depends on the concrete implementation of the respective cron job and can not be described here. Setting the verbose mode for the CronJobService has no effect.

System Cronjobs