Writing your first crontask for Maximo in Jython

Created
Jun 13, 2022 01:40 PM
Tags
automation script
Status
Published
Created Date
In this tutorial I will show you how to write a Crontask for Maximo in Jython and schedule it inside Maximo.
ℹ️
If you are looking for Java based crontask. Please see Writing your First CronTask for Maximo in Java
A Cron Task is a scheduled job which runs periodically at fixed times, dates, or intervals.
This is a very powerful feature of Maximo which can take customization to a new level. In my experience they can be more versatile than Escalations in Maximo.
Follow the following steps to create a Crontask

1. Write the Script in Jython

a. Goto System Configuration – Platform Configuration – Automation Scripts.
Create a new script without any launch point.
notion image
Select jytohn as the script language. Optionally, you can add variables. You can add LITERAL, SYSPROP, and MAXVAR bindings.
To keep it simple, I will add one line which will just print ‘Hello, from my Crontask’ in console.
In the next screen add the following line of code
print 'Hello, from my Crontask'

2. Define a New Crontask in Maximo

notion image
a. Goto System Configuration -Platform Configuration – Cron Task Setup
notion image
b. Create a New Crontask
Click on the new icon to create New Cron Task. Give it any name and for the class enter this com.ibm.tivoli.maximo.script.ScriptCrontask. This is the built in class maximo provides to run automation scripts in crontasks.
notion image
c. Create and schedule an Instance for the crontask
When you select this class. Two new parameters will appear
  • SCRIPTARG – (optional) This is used for passing arguments to script
  • SCRIPTNAME – (required) This is the name of the script you want this cron to run. It is case sensitive.
notion image
In the screen shot above, this instance will run every 10 seconds.

3. Check if the cron Task is running fine.

Make sure Admin Mode is off. In the history tab check if it getting populated with the data.
notion image
and in the code we configured it print out messages which can be seen in log. Goto System.out logs folder and check if messages are being printed there.