Long-running Cron Tasks and Admin Mode

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.

Long-running Cron Tasks and Admin Mode

2 thoughts on “Long-running Cron Tasks and Admin Mode

  1. Hi Bruno
    This is happen in my case, where the BudgetUpdateCronTask taking so long to calculate, your article gave me an insight but still can’t configure how to move the budget Calculation process into an automation script since there are so many things taking into account 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top