In this tutorial I will show you how to write a Cron task for Maximo in Java and schedule it inside Maximo.
If you are looking for crontask in Jython. Please see Writing your first crontask for Maximo in Jython
A Crontask 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. One kye difference between crontask and escalation is that an escalation requires an mbo to be executed upon.
Follow the following steps to create a Crontask
1. Write the Crontask in Java
a. In your IDE write the following code. For the simplest of cron tasks we require to extend this SimpleCronTask class.
SimpleCronTask
class implements the CronTask interface. Some notable methods of this class are below.public voidinit() throws MXException
public voidstart()
public voidstop()
public voidcronAction()
init() is called by the CronTaskManager when the class is instantiated.
start() is called only when the crontask instance is first loaded and active or when it is reloaded and active.
stop() is called when an active crontask instance is interupted by a reload request, or when the contask manager is shutting down
public void cronAction() is the “Core” method of this interface. Here you should implement your logic.
public class FirstCronTask extends SimpleCronTask {
@Override
public void cronAction() {
// Your custom code here. e.g. A sample code is below.
MXServer mxs;
try {
System.out.println("MyFirstCrontask: STARTING CRONTASK");
mxs = MXServer.getMXServer();
UserInfo ui = this.getRunasUserInfo();
MboSetRemote Mbo = mxs.getMboSet("WORKORDER", ui);
Mbo.setWhere("WONUM > 1");
Mbo.reset();
MboRemote row = null;
int i = 0;
if (Mbo.count() > 0) {
while ((row = Mbo.getMbo(i)) != null) {
System.out.println("MyFirstCrontask: DESCRIPTION " + row.getString("DESCRIPTION"));
System.out.println("MyFirstCrontask: WONUM " + row.getString("WONUM"));
i++;
}
}
//End Sample Code
} catch (Exception e) {
e.printStackTrace();
}
}
}
2. Define a New Crontask in Maximo
a. Goto System Configuration -Platform Configuration – Cron Task Setup

b. Create a New Crontask
Click on the new icon to create New Cron Task. Give it any name and give the path for the classfile we wrote in step 1 for this CronTask.

c. Create and schedule an Instance for the crontask

In the screenshot above, this instance will run every 30 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.

or in the code we configured it print out messages which can be seen in log. Goto logs folder and check if messages are being printed there.

Thanks for reading.