Event scheduler cron issues

Hoping to get some advice on some code I have for a custom app.

I cant seem to track down why my scheduled event seems to randomly quit.

I have trimmed the code snippet down to whats releavant.

def initialize(){
unschedule()
state.clear()

//scanTime is set to 30 seconds
schedule("*/${scanTime} * * ? * * *",update)
update() 

}

// Cron Update Cylce Loop
def update(){
debuglog "** update message, should see this every 30 seconds, but it eventually quits working **"
if (!state.delayFlag) sendVentUpdate()
}

// Update the child device vent values
def sendVentUpdate() {
// do some things
delayOn() //turn on the delay so no more updates can happen for a while
}

// Turn on delay
def delayOn(){
state.delayFlag=true
runIn(refresh,delayOff)
}

// Turn off delay
def delayOff(){
state.delayFlag=false
}

I don't see any obvious problems. If you haven't tried the literal app you posted, see if that does the same; otherwise, it's likely something we can't see that you had originally could be interfering--though really only another schedule() or unschedule() should.

If it fails, try going to the App Status (gear icon) page for your app and seeing what is listed under "Scheduled Jobs." You should see, at least, the one you created above, along with the previous and next run times, your cron string, and some other information.

Also, check "Logs" for any errors if anything unexpected still happens.

1 Like

Nothing in the logs when I look other than missing debugs statement, which is how I usually know it stopped working.

When I check the app the scheduled events are usually listed corectly but typically the next event time that is listed has already passed.

Maybe try a soft reset and restore (now very easy with the "Rebuild database on reboot" option under Settings > Reboot -- all you have to do), just to rule out database corruption? (Or try the same app on a second hub if you have one.)

1 Like

tried a reboot with rebuild, also made some code changes, but things still act very strange.

You can see in the picture that it seems to be updated when the next run is, but previous run was four minutes ago. It should be every 30 seconds.

you can see it just radomly decides to run eventually.

So it seems to be getting scheduled to run, it just doesnt actually run.