I have below node cron setup that runs every hour.
const { CronJob } = require('cron');
const Job1 = new CronJob('0 0 */1 * * *', (async () => {
let response = await fetch(`${BASE_URL}/todo`);
response = await response.json();
infoLogger.log({
date: new Date().toISOString(),
level: 'info',
env: process.env.NODE_ENV,
client: CLIENT_URL,
method: 'GET',
api: '/todo',
response,
});
}));
But the problem is it runs every hour the moment app starts. If it was started at 6:15, It will run again at 7:15.
I want it to be run eaxctly at O'clock i.e at 5:00, 6:00 ... 12:00, 13:00 and so on.
So, If app was started at 6:15, It should run again 7:00 and then 8:00 and so on.