Scheduling Server Automation Scripts

In Innovation Studio, you can plan an automation script to run periodically by using the Scheduling feature.

A scheduled job can be set up to run at a fixed interval of time starting with Start Time (Pool Time) or using a Cron Expression.

Pool Time - Refers to the number of threads that can be pooled at once by the underlying Thread Pool Executor the notional number of methods that can be run at the same time.

Cron Expression - Cron runs as a daemon process. This means it only needs to be started once and it will keep running in the background. This process makes use of crontab to read the entries of the schedules and kicks off the tasks. Each line in cron is an entry with an expression and a command to run. This entry runs the mentioned script every single minute.

To schedule a server automation script, follow these steps:

1 Add a scheduled job

  1. From the Innovation Studio main menu, click Automation Blocks > Scheduled Jobs. The Scheduled Jobs List page appears.
  2. At the top-right corner of the page, click the Insert icon. The Add Scheduled Job page appears.
  3. Fill in the mandatory fields (marked with a red asterix).
  4. (Optionally) If you want to set up specific days when the job will not execute, in the Calendar (exclude days) field , provide the code to do so. The types of calendar exclusion can be: ANNUAL (dd.MM), MONTHLY (dd), WEEKLY (days in week: Monday, Tuesday, .etc), HOLIDAY (dd.MM.yyyy).
  5. At the top-right corner of the page, click the Save and reload icon. The record is saved in the system and the Edit Scheduled Job page appears.
  6. Use the Send Notification On Success and Send Notification On Error checkboxes if you wish to send email notifications when a scheduled job succeeds or fails to a preset email address. For information on how to configure the SMTP server to sent notifications for operations, see the Administration Guide.
  7. Tick the Enabled checkbox to enable the scheduled job, otherwise it will not run.

Now you can add schedule services.

2 Add schedule services

  1. In the Edit Scheduled Job page, scroll-down to the Schedule Services section and click the Insert button. The Add Schedule Service page appears.
  2. In the Name field, provide a name for the service.
  3. Click the down arrow next to the Workflow field. A pop-up appears listing all existing server automation scripts.
  4. Select the server automation script you want to schedule by double-clicking on it.
  5. Tick the Async checkbox if you want the service to run asynchronously.
  6. Tick the Mandatory checkbox if you wish to prevent any subsequent services of the scheduled job from running if this service fails.
  7. At the top-right corner of the page, click the Save and close icon to save the record. Add as schedule services as automation scripts you want to schedule for execution.

If you have more than one scheduled service in the Schedule Services list, you can set their execution order.

3 Set the execution order

If you have several automation scripts scheduled and need them to be run in a specific order, drag and drop the records in the Schedule Services list in their execution order (where the first record in the section is the first one to be executed).

If you choose that one of the service is mandatory and it fails, all the following services (scripts) will no longer execute. Also, if you will choose to run script async (when adding /editing a schedule service by selecting the Async checkbox), the order of services will be disregarded and all automation scripts will run in parallel.

Copy

[{
        name:"calAnual",
        type:"ANNUAL",
        excludeDays:["03.11","17.01"]
      },
    {
        name:"calMonthly",
        type:"MONTHLY",
        excludeDays:["25","10"]
    },
    {
        name:"calWeekly",
        type:"WEEKLY",
        excludeDays:["Saturday","Sunday"]
    },
    {
        name:"calHoliday",
        type:"HOLIDAY",
        excludeDays:["25.12.2018","01.01.2019"]
    }
]        
NOTE  
In order for the cron jobs to trigger the automation script execution, the Job Server should be installed on deployment.

The Job Server is aware of jobs changes (time, cron expression, reorder of services).

For all failed jobs, a Run now button is displayed which allows running the jobs again. The job data model has includes a parent job id. When running a failed job (by clicking the Run now button), a copy of the job is created having the parentJobId = original Job and it will be scheduled to run only once in 1 minute.