0

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?

advapi
  • 3,661
  • 4
  • 38
  • 73
  • Take the timezone from the client and use it to schedule execution. Time savings should be implemented correctly in the library you are using. Test some other lib perhaps? – Vallerious Sep 04 '20 at 13:52
  • how do I get the timezone? – advapi Sep 04 '20 at 13:56
  • It depends whether you have some remote client/web browser/rest client that triggers this. As part of the request to your scheduler you can pass the timezone. – Vallerious Sep 05 '20 at 08:50
  • ok but excuse me , I've tried doing on both machines, mine and the production one and it always returns -120 calling the ```new Date().getTimezoneOffset()``` ... is this different from the nodejs one? – advapi Sep 07 '20 at 14:13

0 Answers0