Example: Scheduling Tasks with Time and Calendar Conditions

In this example, a Schedule automates the cyclical execution of three tasks, two Workflows (JOBP.X and JOBP.Y) and one Job (JOBS.AA), each with different time constraints.

What Will You Learn?

  • How to create a Schedule object and define its basic settings.
  • How to add tasks to a Schedule.
  • How to define time and Calendar conditions to the tasks.
  • How to activate the Schedule object and, if necessary, reset a task with TIMEOUT status.

What Does this Example Cover?

A Schedule object automates the execution of three tasks. Each task should start at a specific time. The following time constraints apply:

  • JOBP.X should be executed every day at 7 am.
  • JOBP.Y should be executed only on every first day of the month at 01:00 pm (13:00)
  • JOBS.AA should be executed every Wednesday at 07.00 pm (19:00)

The Schedule should execute once a day, that is, its Period Duration is 1. A new period should start at 00:00 (Period Turnaround Time). This is the time at which completed tasks are removed from the Schedule and loaded anew to be executed again the next day.

Overview

The following list provides an overview of the steps you must carry out:

  1. Create and Define the Schedule Object
  2. Add Tasks to the Schedule
  3. Apply Time and Calendar Conditions to the Tasks
  4. Activate the Schedule Object
  5. ENDED_TIMEOUT Status - Resetting the Task
  6. What Happens Now?

Create and Define the Schedule Object

  1. Log in to your Client and open the Process Assembly perspective.
  2. Navigate to the folder in which you want to create the Schedule object.
  3. Click Add Object on the toolbar (alternatively, right-click anywhere on the list and select Add > Add Object).
  4. Select Schedule (JSCH) and click Add.
  5. The Schedule definition pages open displaying the Schedule page. Switch to the Attributes page.

    Here you define Schedule settings such as its periodicity (in our case one day) and the time at which a new period starts (00:00).

    Screenshot of the Attributes page of a Schedule object where the following has been entered: Queue - Queue.Scheduler, Preiod turnaround time - 12:00 AM, Period Duration - 1 Day.

Add Tasks to the Schedule

  1. Open the Schedule page.
  2. Activate the first row by clicking on it and click the folder icon. This opens the Select Object dialog.
  3. Search for and select the first task (JOBP.X) and click OK. It is inserted in the task list.
  4. Click Add Row on the toolbar and add the second (JOBP.Y) and third (JOBS.AA) tasks to the Schedule.

    By default, added tasks are set to Active. This means that they will be executed according to the Schedule and task settings you are about to define. If you deactivate this checkbox, the task remains in the Schedule but it is not executed.

Note: The Schedule now contains all the tasks that it will automate. Now you define the task start times and their calendar conditions.

Apply Time and Calendar Conditions to the Tasks

  1. Select JOBP.X to activate it and type the time you want it to start its execution. In our case, this is 07:00.

    JOBP.X needs no further time or calendar settings, so you can proceed with the next task.

  2. Select JOBP.Y to activate it and type 13:00 in Start Time.
  3. Click the Properties button on the toolbar. This opens a pane at the bottom half of the window that displays the task properties.
  4. On the Calendar tab activate the Set Calendar Conditions checkbox.
  5. Specify when you want the task to be executed taking the Calendar definitions into account. In our case, this is Execute if one condition matches.

    For more information, see To Define the Periodicity and Time Settings of a Schedule Object.

  6. Add a Calendar.

    1. Activate the first row by clicking on it or click Add Row to add a new one.
    2. Select a Calendar from the list. In our case, it is called USEFUL.CALENDAR.

      Alternatively, start typing the name of the Calendar to activate the "select as you type" function.

    3. Select a Calendar Event. In our case it is FIRST_OF_MONTH.
  7. Select JOBS.AA to activate it and type 19:00 in Start Time.
  8. Assign it a Calendar and a Calendar Event as described above. In our case, this is again USEFUL.CALENDAR but the Calendar Event is WEDNESDAY.

    Screenshot of the Schedule page showing the populated Calendar tab, where the USEFUL.CALENDAR Calendar and the wEDNESDAY Calendar Event are selected.

Note: The Schedule object is ready. Now you must activate it.

Activate the Schedule Object

Expand the Execute button on the toolbar and select Execute Once.The Schedule is started. A message is displayed at the top of the window that confirms it.

Screenshot of the popup messages where the following can be read: Schedule object successfully started. Open Monitor. Open Monitor is a link that leads to the Schedule monitor.

The Schedule is now in Active status, which means that it will execute the first task as soon as all the required conditions are met considering the Schedule Period Turnaround Time and Period Duration as well as the Start Time and Calendar Condition of each task.

You can open the Process Monitoring perspective and search for it in the list of tasks to check it.

Screenshot showing the task in the Process Monitoring perspective, where the JSCH.SCHEDULE.EXAMPLE task is highlighted and it shows the status Active.

To check the status of the tasks in the Schedule and follow their progress, modify its parameters, open the execution data and reports, etc., you need the Schedule Monitor. Click Last Monitor on the toolbar to open it.

Screenshot of the Schedule monitor showing the status of the tasks within the Schedule.

ENDED_TIMEOUT Status - Resetting the Task

In our example, JOBP.X has a different status, namely ENDED_TIMEOUT - Start time exceeded. This is because its Start Time is set to 07:00 and we have defined the Schedule, added JOBP.X and defined its Start Time after 07:00 today. JOBP.X has no further date/time restrictions, it should execute everyday, that is, today the Schedule has missed an execution.

To activate this task and make sure that the Schedule processes it appropriately, select it and click Reset Task.

Screenshot of the Schedule Monitor highlighting the Reset Task button.

As a result, JOBP.X executes immediately.

What Happens Now?

  1. As soon as the Period Turnaround Time arrives, the tasks are Waiting for Start Time.

    Graphic that depicts a timeline that represents the execution schedule of three tasks: JOBP.X, JOBP.Y, and JOBS.AA, across three days: Monday, March 31st; Tuesday, April 1st; and Wednesday, April 2nd. The timeline is marked with time intervals of 7:00, 13:00, and 19:00, as well as 00:00, which indicates the start of a new day. Monday, March 31st: At 00:00, all three tasks (JOBP.X, JOBP.Y, and JOBS.AA) are in a Wait for Start Time status.

  2. At 07.00 JOBP.X becomes Active; it is executing. The other two tasks are still in waiting status until 13:00 and 19:00 respectively:

    The image is a timeline that visualizes the execution of three tasks, JOBP.X, JOBP.Y, and JOBS.AA, within a schedule across three days: Monday, March 31st, Tuesday, April 1st, and Wednesday, April 2nd. The timeline is marked with time intervals of 7:00, 13:00 (1:00 PM), and 19:00 (7:00 PM). On Monday, March 31st, at 7:00 AM, JOBP.X is marked as Active, while JOBP.Y and JOBS.AA are Wait for Start Time.

  3. At the end of the day, JOBP.X ended OK whereas the other two tasks are inactive because the Calendar conditions did not allow them to execute. JOBP.Y should be executed on the first day of the month and JOBS.AA on Wednesdays only; neither of these conditions apply on Monday 31 March:

    Graphic illustrating the execution status of three tasks, JOBP.X, JOBP.Y, and JOBS.AA, across three days: Monday, March 31st, Tuesday, April 1st, and Wednesday, April 2nd. The timeline includes these key details: Monday, March 31st: JOBP.X is marked as ENDED_OK, while both JOBP.Y and JOBS.AA are marked as INACTIVE-Calendar.

  4. The next day the tasks are loaded again at midnight and are waiting for their Start Times:

    Graphic illustrating the execution of tasks within a schedule across three days: Monday, March 31st, Tuesday, April 1st, and Wednesday, April 2nd. The timeline is marked with time increments of 7, 13, and 19. Monday, March 31st: A gray bar extends from 00:00 to just before 00:00 on April 1st. On Tuesday, April 1st all three tasks are in a Wait for Start Time status

  5. On Tuesday 1 April, JOBP.X executes at 07:00 and JOBP.Y at 13:00 (it is the first of the month so the Calendar conditions are met). JOBS.AA does not execute because it is not a Wednesday:

    Graphic illustrating a timeline from Monday, March 31st to Wednesday, April 2nd, with time increments of 00:00, 7, 13, and 19 hours marked for each day. The timeline displays the execution status of three tasks: JOBP.X, JOBP.Y, and JOBS.AA at 10:03 pm. A gray bar extends from 00:00 to just before 00:00 on April 1st. The status for each task on Tuesday is as follows: JOBP.X is ENDED_OK, JOBP.Y is ENDED_OK, and JOBS.AA is INACTIVE_Calendar.

  6. The next day, JOBP.X executes at 07:00 and JOBS.AA at 19:00 (it is a Wednesday). JOBP.Y does not execute because it is not the first of the month:

    Graphic illustrating a timeline from Monday, March 31st to Wednesday, April 2nd, with time increments of 00:00, 7, 13, and 19 hours marked for each day. The timeline displays the execution status of three tasks: JOBP.X, JOBP.Y, and JOBS.AA on Wednesday. The status of wach task is as follows: JOBP.X is ENDED_OK, JOBP.Y is INACTIVE_Calendar and JOBS.AA is ENDED_OK.

Useful Links

This example contains references to a number of functions that you might want to know a bit more about.