node-cron icon indicating copy to clipboard operation
node-cron copied to clipboard

Cron expression at 12 am Asia/Kolkata doesn't trigger cronJob expression "0 0 0 * * *"

Open bhaskarb360 opened this issue 3 years ago • 3 comments

Description

When I deployed to azure servers and running on 3rd Feb 2022 if I set 12 am cron expression "0 0 0 * * *" should trigger on 4th Feb 2022 doesn't triggers.


 masterCronJob = new CronJob("0 0 0 * * *", async()=>{
            console.log("starting setting users subscription validity at 12 am IST",moment().format());
            await checkUserValidity();
        }, null, true, 'Asia/Kolkata');

While if change or use any other expression like "0 36 0 * * *" triggers right way at the right time is being set with the timezone.

What could be the issue?

Screenshots

Doesn't trigger cronJob at 12am image

Additional information

No response

bhaskarb360 avatar Feb 03 '22 19:02 bhaskarb360

Check out github.com/hexagon/croner for a great alternative, pay special attention to the "Why another JavaScript cron implementation?"

Hexagon avatar Feb 04 '22 22:02 Hexagon

Check out github.com/hexagon/croner for a great alternative, pay special attention to the "Why another JavaScript cron implementation?"

Does croner allows to add timezone apart from Europe ? Also can we use Momentjs values ?

anogray avatar Feb 05 '22 09:02 anogray

Yes, croner supports all time zones.

And if you refer to using a Date as cron pattern to run a one-off job, it is supported. Croner use ISO 8601 time strings for all string input, which can be generated by moment using dateObj.format().

Hexagon avatar Feb 06 '22 09:02 Hexagon