2

I wrote a schedule/cron job with the following expression

"0 9-17 * * *"

as I wanted it to run everyday from 9am to 5pm, every hour. However the callback function was only executed for day 1 and not for everyday.

const job = schedule.scheduleJob("0 9-17 * * *", async () => {
// my code
})

Please do highlight my mistake.

N.A
  • 187
  • 1
  • 1
  • 5

1 Answers1

2

this should help you with the issue -> https://cron.help/every-5-minutes-between-9-and-5

If you want cronjob to run everyday between 9 to 5 and lets say each 5 miuntes it would be like this:

*/5 9-17 * * *

If you want to run it every minutes you should do something like:

*/1 9-17 * * *

To run it between 9-17 each hour use:

*/60 9-17 * * *

enter image description here

Aljaz
  • 303
  • 4
  • 18
  • I wanted to run it with an hour gap like first at 9 am then at 10 am then 11am and so on till 5pm – N.A Dec 07 '21 at 08:07