How to debug the cronJob

Hi,
I’d like to know how I can debug my cronJob instance.
This is the context:

  • I have 1 instance of cronJob:
    "id" : "refresh_FS",
    "name" : "refresh_FS",
    "description" : "CronJob set every 30 seconds ",
    "action" : {
      "typeName" : "Type_RefreshJob",
      "actionName" : "scheduledStart"
    },
    "inputs" : {
      "this" : {
        "type" : "Type_RefreshJob",
        "id" : "my_id"
      }
    },
    "concurrent" : false,
    "scheduleDef" : {
      "cronExpression" : "0/30 * * * * ?",
      "skipOverdue" : true
    },
    "inactive" : true
      }
  • An instance of Type_RefreshJob:
{
    "id" : "my_id",
    "options" : {
            ...
    },
    "priority" : 300,
    "maxConcurrency" : -1,
    "maxConcurrencyPerNode" : -1
  }

  • In Type_RefreshJob.c3typ the function scheduledStart() start the job;
  • After provisioning I run this command on console:
    CronJob.make({id: "refresh_boilerLeakage_predictions_FS", inactive: false}).merge().

So, if I run c3Grid(CronQueue.countAll()) I see the cronJob switch from initial to failed.

Which is the best way to debug the cronJob?

Thank you

Run c3QErrs(CronQueue) to see what the errors are. In 7.9 this will be greatly improved.

Hi
I’m trying to debug my CronJobs and I am getting the following message with c3QErrs(CronQueue)

Unable to coerce json value of MyPackagePredictionJob.scheduledStart#this to mixing MyPackagePredictionJob

This is the seed data for the CronJob:

{
    "id" : "refresh_predictions",
    "name" : "refresh_predictions",
    "description" : "CronJob set every 5 minutes for prediction",
    "action" : {
      "typeName" : "MyPackagePredictionJob",
      "actionName" : "scheduledStart"
    },
    "inputs" : {
      "this" : {
        "type" : "MyPackagePredictionJob",
        "id" : "MyJob"
      }
    },
    "concurrent" : false,
    "scheduleDef" : {
      "cronExpression" : "0 0/5 * * * ?",
      "skipOverdue" : true
    },
    "inactive" : true
  }

If you run the function from console with the inputs mentioned - does it work?

MyPackagePredictionJob. scheduledStart()

I’m not sure about the this structure in inputs

Yes Marco, we have already used that property field on other schedules. Is there a better way to monitor CronJob executions?

@rghera You need to specify the type differently for the “this” input arg:

{
"id" : "refresh_predictions",
"name" : "refresh_predictions",
"description" : "CronJob set every 5 minutes for prediction",
"action" : {
  "typeName" : "MyPackagePredictionJob",
  "actionName" : "scheduledStart"
},
"inputs" : {
  "this" : {
    "type" : {
      "name" : "MyPackagePredictionJob"
    },
    "id" : "MyJob"
  }
},
"concurrent" : false,
"scheduleDef" : {
  "cronExpression" : "0 0/5 * * * ?",
  "skipOverdue" : true
},
"inactive" : true
}

I added the new version of the JSON in my CronJob definition, but I am getting exactly the same error.

@rghera looks like the scheduleStart is a member function - I think you should invoke using something like MyPackagePredictionJob.get('IDOFTHEJOB'). scheduledStart() instead you are passing an argument to the function

@rghera your “inputs” property should look like

“inputs”: {
“this”: {
“type”: “MyPackagePredictionJob”,
“id”: “MyJob”
}
}

when you do c3Grid(CronJob.get(‘refresh_predictions’)), do you see that same structure for the inputs property or do you have an extra value property in there?

@rghera changin the inputs like this fixed the issue

CronJob.merge({id:"refresh_predictions",inactive:false,inputs:{
     this: myjob.get('jobid')
   }
})

Looks like it is running but is failing in the doStart complaining about the “flag” please take a look
credit to @AlessandroT

The function stopped working from yesterday afternoon. Is it a consequence of some update on the platform version?

@rghera and @marcosordi Please keep in mind that CronJob mixes in SeedData. As such, if you change things manually (via upsert/update/merge, etc.) and you then change the json and provision, the new values in the json will be ignored because the field was user updated. I suspect that may be why you are seeing the same error.

When merging or removing Type instances, Is it possible to use a spec like {ignoreSeed:true} to avoid that behaviour?

@rghera Look at the SeedData.c3typ documentation. There are functions such as createSeedData/updateSeedata/removeSeedData and their batch versions that do what it sounds like you are requesting.