1

I'm using https://www.npmjs.com/package/cron version is ^1.7.2. Normally it scheduled at 10:40 PM everyday and it works well on that part. The problem that i want to solve is when i run my code by using node app.js it run main() function first then it wait for scheduled time. I want to cancel automatically running on start. Here is my code below,

CronJob('22 40 * * *', main(), null, true, 'Europe/Istanbul');
zemil
  • 3,235
  • 2
  • 24
  • 33
  • 2
    @Quentin, are you going to mark duplicate every question that receives a function as a parameter and mistakenly added parenthesis, or only those related to timers? – niry Nov 14 '19 at 00:15

1 Answers1

2

Your code is scheduling the results of main() instead of main. Do it without the parenthesis:

CronJob('22 40 * * *', main, null, true, 'Europe/Istanbul');
niry
  • 3,238
  • 22
  • 34