Creating cron tasks that run automation scripts

When an automation script runs as part of a cron task, the automation script does not require a launch point. You reference the com.ibm.tivoli.maximo.script.ScriptContask Java™ class in your cron task definition, and then you can attach an automation script to the cron task.

About this task

Cron tasks are jobs that run automatically on a fixed schedule on the application server. For example, the ESCALATION cron task processes escalations to ensure that critical tasks are processed on time. You can use several predefined cron tasks and you can also define new cron tasks. For new cron tasks, you must provide a Java class implementation that contains the business logic that is executed on a schedule. By using this Java class reference in your cron task definition, you can attach an automation script that provides the business logic that is executed by the cron task.

Procedure

  1. In the Automation Scripts application, on the List tab, select the Create > Script action.
  2. Specify a name, description, and log level for the script.
  3. If the script requires variables, in the Variables section, add new rows to declare the variable and bindings.
    You cannot specify bindings to a Maximo® business object. You can specify only LITERAL, SYSPROP, and MAXVAR bindings.
  4. Enter the source code of the automation script and click Create to save the automation script in the database.
  5. In the Cron Task Setup application, create a new cron task definition.
  6. In the Class field, enter com.ibm.tivoli.maximo.script.ScriptCrontask.
  7. Create the cron task instance that runs the automation script.
    1. In the Cron Task Instances section, add a row.
    2. Specify the cron task instance name.
    3. Set the schedule for when the cron task is run.
    4. Select Run As User.
      The security authorizations that are granted to the specified user determines whether business logic that is related to Maximo business object can run in the script code.
      For example, a value cannot be set in a record unless the specified user has the security authorization to write values into that record.
  8. In the Parameters tab, in the SCRIPTARG row, specify a value that represents an argument for the cron task.
  9. In the SCRIPTNAME row, specify the name of the script that you created to run as part of the cron task.
    SCRIPTNAME is a mandatory parameter that must be populated. The script name that you specify is passed to the automation script in the form of the scriptName implicit variable.
  10. In the Details section, select the Active check box to activate the cron task instance.
  11. Save the record.