I have a scheduled hourly job that is supposed to get launched at the start of every hour. The job is implemented and it is getting started by the scheduler (most of the time). However, literally every day it does not start sometimes (sometimes even two hours in a row). I am not describing a situation where it starts and fails. The app logs literally list nothing at all for that hour. Nothing was started. Also, all previous jobs are listed as complete in the same app logs.
What I’ve tried and what’s not working:
Nothing really to clarify here. A simple task that loads content/data to a GUI is supposed to be started in the background every hour. It gets started and executes properly most of the time but inevitably “skips a beat” (as in nothing happens and there is nothing in the logs) several times every day.
How long do these tasks take to complete? Anvil will not launch a new instance of a Scheduled Task if the previous instance hasn’t finished yet (this is to avoid accidentally bringing your app to a crawl by launching, eg, a 10-minute-long job every minute!). Can you try modifying your task to log the time of its completion, to check whether the previous instance had completed at the time of the “skipped beat”?
The tasks take a few mins. The app logs show that all the tasks that started before the missing ones were complete within a few mins. As you suggested, I have extensive logging on the activity of the same tasks and it has literally never been the case that such a task has continued more than a few mins. The menu that covers background tasks in Anvil also shows all such hourly tasks complete within a few mins … well before the expected start time of the next task - at the next full hour.
I realize that this is very general but the problem is difficult to explain more precisely. There is literally a task that does not always and consistently get started when scheduled despite the fact that there is absolutely nothing else is going on. Btw, even when it does get started, it is sometimes up to 15 mins after the specified full hour time/moment.