There are many blog posts in the Maximo technical community describing how to develop an automation script and schedule execution using a cron task (link1, link2).
However, a custom cron task may run for a long period of time and this may block the system when trying to enable administrative mode. In this case you will see a long list of BMXAA9680I Crontask is running messaged in the “Turn Admin Mode ON” dialog.
To solve this problem, you must use the MXServer.isAdminModePending() method to check if the system is trying to enter Admin Mode and stop processing in you cron task script.
In the following example I’m looping on all tickets and waiting for a second on each record. This can run forever if you have a lot of tickets. Calling isAdminModePending will exit the loop when trying to enter Admin Mode.
from psdi.server import MXServer
from java.util.concurrent import TimeUnit
logger = service.getLogger("maximo.cx")
logger.info("Entering CX_TESTCRON")
mxs = MXServer.getMXServer()
srSet = mxs.getMboSet('SR', runAsUserInfo)
sr = srSet.moveFirst()
while (sr):
if mxs.isAdminModePending():
logger.info("Exit!!!")
break
logger.info("Ticket " + sr.getString("TICKETID"))
TimeUnit.SECONDS.sleep(1)
sr = srSet.moveNext()
srSet.close()
logger.info("Exiting cron task CX_TESTCRON")
Long-running escalations cannot be interrupted with the technique described in this post. However, if you have custom escalations blocking the admin mode for long period of time you can convert them into cron tasks.
Thanks for a useful addition that should be in every custom crontask