1

I want to run a background script every day at midnight after every 10 minutes. It should run on 00:10, 00:20, and so on What I have tried is.

schedule.scheduleJob("1 0-23 * * *", async () => {

})

What I want is to find a way to start this job at midnight and should be run after each 10 minutes

jones
  • 1,423
  • 3
  • 35
  • 76
  • Possible duplicate of [I need a Nodejs scheduler that allows for tasks at different intervals](https://stackoverflow.com/questions/20499225/i-need-a-nodejs-scheduler-that-allows-for-tasks-at-different-intervals) – BlackBeard Apr 16 '19 at 08:48
  • What do you mean by `start at midnight`? – Shaharyar Apr 16 '19 at 09:16
  • @Shaharyar I want to start this background job at 12 pm and recursively should be run after every 10 minutes, something like `12:00, 12:10, 12:20, ......` – jones Apr 16 '19 at 10:44

1 Answers1

0

In your case schedule must be: */10 * * * * – run every 10th minute.

I'm not sure what you mean by starting at midnight. When it should finish then?

Update based on comment:

If you want to run it during the interval of 12 PM to 10 AM you'll need to specify the hour parameter. And it'll look like this: */10 0-10 * * * - every 10th minute past every hour from 0 through 10

start at 00:00:00 
then at 00:10:00 
then at 00:20:00 
... 
finish at 10:00:00

Hint: you can use crontab.guru to play with Cron formats.

Iurii Tkachenko
  • 3,106
  • 29
  • 34
  • I use this for mailing, I want to start mailing service at 12 pm and run in every 10 minutes. My total mailing list is around 60K, in each circle (10 minutes) I'm sending 700 emails, so it will be finished at 10 am, after finishing, I can kill the task. – jones Apr 16 '19 at 10:09
  • So then it'll: `*/10 0-10 * * *`. Updated the answer. – Iurii Tkachenko Apr 16 '19 at 12:46