Job scheduler - Not working

I have a Job scheduler which I can not get to work:

My jobs.config :

// /backend/jobs.config
{
 "jobs": [
    {
       "functionLocation": "/timer.check",
       "description": "Check for events",
       "executionConfig": {
         "time": "13:52", // mandatory, “hh:mm” format
      }
    },
    {
     "functionLocation": "/timer.check",
     "description": "Check for events 2",
     "executionConfig": {
       "time": "15:52", // mandatory, “hh:mm” format
      }
    },
    }
  ]
}

My function located in timer.js in the backend:

export function check () {
    console.log("Checking for new events")
    clearInterval(interval)
    let interval = setInterval(() => {
        console.log("Checking for new events")
    },2000)
}

I am living in UTC + 2 and therefore made sure to subtract 2 hours from my current time to enter the correct time in UTC in the jobs.config.

@robert-hamilton fyi

@liorwi

Hi Leon,
Quick glance at your Job scheduler JSON object I found some errors that you might have missed in the config file.

Please give an update after you implement this fix

Thanks for your answer. The function is now being executed. However after a couple of minutes it stops. Does config kill the functions after a certain amount of time? I need to run a function in the backend every 10 seconds.

jobs.config (now working):

{
 "jobs": [
    {
       "functionLocation": "/timer.check",
       "description": "Check for events",
       "executionConfig": {
         "time": "09:28" 
      }
    }
  ]
}

timer.js:

export function check () {
    console.log("Checking for new events")
    let interval = setInterval(() => {
        console.log("Checking for new events")
    },10000)
}

[@leon] I suspect that the job runs once and then exits. This is likely to be a cron job on the server which probably won’t allow a “secondary” timer to execute. This could tie up resources unnecessarily if lots of people do this. The idea behind jobs is to manage recurring batch functions that don’t need user interaction.

To do what you are trying to do I think you will only get a minute resolution and you would need a job to run every minute so a JSON file with around 1440 entries (one per minute).

I would say a feature request may be needed.

Okay, thanks. Yes, this feature would be nice. I will make a request.

Thanks, I was having the same issue with the JSON formatting. Wish I had known to take out any comments.

Is there a way to automatically get a log of all scheduled events that run, as well as their success/failure?

@liorwi