nodejs schedule with timezone and saving light

385 views Asked by At

I'm trying to schedule some job on nodejs using node-sched (I've also tried node-cron-tz which supports timezones), on my current dev machine it works correctly and works fine.. on customer test/prod env it executes it 2 hours later.

I need to perform this job at the time present on a DB and it's normally 0 8 * * *

The code I used in my latest test is

scheduleService.addSqlTask = function (item) {
    if (item == null)
        return;

    logger.info('Adding job {Item} to schedule', {Item:item.stored_procedure});
    //logger.info("Adding {Item} : {Cron}  to tasks", { Item: item.stored_procedure, Cron : item.cron_tab });
    cron.schedule(item.cron_tab,
        async () => {
            try {
                logger.info("Executing {Item} to schedule", { Item: item.stored_procedure });
                await dataStore.executeSql(item);
            } catch (e) {
                logger.error(e.message);
            }
        },
        {
            scheduled: true,
            timezone: "Europe/Rome"
        }
    );
}

In this case, it works wrong even on my machine since it doesn't consider saving light...

How can I handle this?

0

There are 0 answers