Job Scheduler

The scheduling module allows users to schedule tasks that have been previously registered in Kuwaiba through the Task Manager module (refer to the Task manager documentation). Scheduling module allows you to schedule tasks precisely using cron expressions. You can configure tasks to run every n seconds, minutes, or hours, or at a specific day and time. For example, you can execute a task every 2 hours. It's also possible to schedule tasks to run on a specific day and time, such as August 15th at 12:00 PM, or on the 1st of every month at 6:00 AM. Additionally, you can set tasks to execute on a specific day of the week, like every Monday at 8:00 AM. This module offers flexibility in scheduling tasks as needed.

Figure 1 shows the structure of the module, where all jobs are organized into a pool. Pools are groupings of similar objects in this case, jobs and can contain one or more elements. The jobs are related to one or more users using the HAS_USER relationship. Similarly, a job can only be related to a single task through the HAS_TASK relationship, which indicates the task that the job will execute when its schedule is met.

Scheduling Module
Figure 1. Scheduling module structure

The scheduling module belongs to the Administration category as shown in Figure 2.

Scheduling Module
Figure 2. Scheduling module

Scheduled Job Pool

Once the scheduling module is open, you need to create a job pool, which will allow you to create and manage jobs in an organized manner. To do this, locate the pool management button represented by a gear iconButton Manage Poolsas shown in Figure 3.

Manage Pools
Figure 3. Manage pools button

Once clicked, the pool management window will open, as shown in Figure 4.

Manage Pools Window
Figure 4. Manage pools window

In this window, you can search, create, and delete job pools. Next, create a new job pool using the buttonButton Create Pools seen in Figure 4. The pool creation window shown in Figure 5 will open, where you must enter the name and description and click the OK button.

Pool Creation Window
Figure 5. Pool creation window

Al crear el pool de job, se pueden visualizar las jobs que tiene asignados, eliminar el pool usando el botón Button Delete Pool y editar sus propiedades utilizando la hoja de propiedades de la Figura 5.

When creating the job pool, you can view the jobs assigned to it, delete the pool using the buttonButton Delete Pooland edit its properties using the properties sheet shown in Figure 6.

Pool Property Sheet
Figure 6. Pool property sheet

Scheduled Job

A job consists of the following properties:

PropertyDescription
Job poolsPool to which the job will be assigned
NameName of the job
DescriptionDescription of the job
UsersUsers assigned to the job
TaskTask assigned to the job that will be executed
CronExpressionExpression that designates the time at which the job should be executed
EnableFlag to enable or disable the execution of the job
LogResultsFlag to enable or disable logging of execution results in the console

Once the job pool is created, the button to add jobsButton Create Jobwill be enabled in the main menu of the module, as seen in Figure 7.

Button Create Jobs
Figure 7. Create jobs button

Pressing it will open the job creation window shown in Figure 8.

Window Create Jobs
Figure 8. Jobs creation window

To create the job, follow these instructions:

  • Select a pool in Jobs Pool combo box allows you to assign the new job to the desired pool.

  • Fill in the text fields for Name and Description.

  • Select a tasks in Select Task combo box allows you to assign the task to be executed by the job. This task must have been previously registered in Kuwaiba through the Task Manager module.

  • Use the buttonButton Add Usersallows you to assign users available in Kuwaiba to the job. These users will be notified of the task execution result (this feature will be added in the future and is not yet available).

  • Fill Execute, this combo box allows you to select the job execution (CronExpression). The scheduling options include the following:

  • Every: Enables the execution of the job at short intervals, ranging from seconds to hours.
  • Daily: Allows daily execution of the job at the selected time of day.
  • Weekly: Enables weekly execution of the job. You must select the desired day of the week and time.
  • Monthly: Enables monthly execution of the job. You must select the desired day of the month and time. (If you select the 30th of each month, execution will be skipped in months with fewer than 30 days).

If all mandatory properties marked with * are filled in correctly, the OK button in the job creation window from Figure 8 will be enabled.

Note Before creating or scheduling a job, ensure that the scheduler user is created in the application. If not, create it in group system with the name scheduler and type System. For more details on how to create users, refer to the User Manger, which explains this in detail.

When a new job is created, it will be scheduled and queued to be executed according to the assigned execution interval. It can be viewed in the main window of the module as seen in Figure 9. Upon creating a job, it will automatically be scheduled every time the application starts. If for any reason you do not want it to be executed, you can disable its execution by setting the Enable property to False or by deleting the job.

Once the job is executed, the result of its execution will be logged in the general events of the AuditTrail using the user scheduler. You can refer to AuditTrail for more details.

Scheduling
Figure 9. Jobs scheduled

When left-clicking on a job, the property sheet shown in Figure 10 will appear. This property sheet allows you to edit the properties of the job after it has been created.

Scheduling
Figure 10. Job property sheet

All properties of a job seen previously can be edited by double-clicking the desired property on the property sheet.

To edit the cronExpression property, double-click on it. This will prompt the cronExpression editing popup window shown in Figure 11, which behaves similarly to when creating and assigning the execution of a new job. Once you've chosen the new job execution, click OK to edit, or Cancel if you don't wish to edit this property.

Edit CronExpression
Figure 11. Edit cronExpression property window

Similarly, to edit the users assigned to the job, double-click on the users property. This will display the selection list of available users in Kuwaiba, as shown in Figure 12. Add or remove the users you want to assign or unassign from the job, then click OK to edit or Cancel if you don't wish to edit this property.

Edit Users
Figure 12. Edit users property window

Finally, to edit the task that the job should execute, double-click on the tasks property. This will open the task editing window shown in Figure 13, where you can choose any task registered in the Task Manager. Once you've selected the task, click OK to edit or Cancel if you don't wish to edit this property.

Edit Tasks
Figure 13. Edit tasks property window

Jobs have four possible states, which inform the user about the execution status of the jobs that have been scheduled. The status can be viewed in the central part of the main window of the module. The available states are:

  • Scheduled: Indicates that the job has been scheduled correctly and is waiting to be executed. Scheduled
  • Running: Indicates that the job is currently running (it cannot be edited during this time). running
  • Executed: Indicates that the job executed successfully in its last execution. executed
  • Error: Indicates that an error occurred in the last execution of the job. fail

Finally, it's possible to view the list of jobs associated with a pool or all created jobs using the pool selector located on the left side of the main window. It's also possible to filter the results by job name. Additionally, this list allows you to delete a job using the buttonButton Delete Jobas shown in Figure 14.

List Jobs
Figure 14. List of jobs