Skip to main contentCarbon Design System

Scripting cron tasks in Maximo

You can write scripts for cron tasks from Maximo 7.6. It follows the same principle as the endpoint handler. The cron class, helps achieve this. You must register that class as a new crontask in the crontask application. You must then create an instance of it and set the “scriptname” property to the name of the script that you want this task to run. Set the schedule and define the script. You can now run this newly defined script with the crontasks. It is no different from any other crontask and you can activate or deactivate the task or change the schedule as you would do in any other cron task.

You must do this even if you already have an escalation, which is a crontask based on a Maximo object. This is because you may be required to schedule jobs that are not just based off Maximo objects. In those cases, these crontask based scripts would come in handy.

The following steps develop a cron script to log an error when the count of maxsessions exceeds a configured limit.

  1. Register the script crontask definition. For that you will use the Crontask app and the class name would be You will also create a cron task instance. In that instance, you can set the frequency to 30 sec. You can set the SCRPTNAME param value to SESSIONCOUNT. This will create a script named SESSIONCOUNT to do the job.

  2. Create the script SESSIONCOUNT. The following sample script is in py. The “runasUserInfo” implicit var will hold the userinfo for the cron job.

from psdi.server import MXServer
cnt = MXServer.getMXServer().getMboSet("maxsession",runAsUserInfo).count();
if cnt>1:
service.logError("cnt exceeds 1::"+str(cnt))
  1. Activate the crontask instance. You should wait a minute or so for the task to start. You can use another browser instance to login to Maximo to create another maxsesson record. That is when you can see that log that says “cnt exceeds 1::“.

  2. You had hard coded the count limit. In this step you can softcode this by leveraging the SCRIPTARG parameter in the Crontask by setting it to 1. Save and reload the task.

  3. Modify the script to leverage that SCRIPTARG parameter using the implicit var called “arg” .

from psdi.server import MXServer
argval = int(arg)
cnt = MXServer.getMXServer().getMboSet("maxsession",runAsUserInfo).count();
if cnt>argval:
service.logError("cnt exceeds 1::"+str(cnt))
  1. Repeat step 3 to check if you get the error log.