1

I want to execute the message daily at 10'o clock 5 minutes 25 seconds but I tried the program I got an error:

ERROR OCCURED: 
  throw patterns[5] + ' is a invalid expression for week day';
      ^
 is a invalid expression for week day

Code:

var cron = require('node-cron');
cron.schedule('25 05 10 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 January,February,March,April,May,June,July,August,September,October,November,December   Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday ', function(){
    console.log('Time for breakfast');
});
halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

2

The cron syntax is as described in the node-cron library page:

┌────────────── second (optional)
│ ┌──────────── minute
│ │ ┌────────── hour
│ │ │ ┌──────── day of month
│ │ │ │ ┌────── month
│ │ │ │ │ ┌──── day of week
│ │ │ │ │ │
│ │ │ │ │ │
* * * * * *

So, for executing the task every day at 10:05:25, try 25 5 10 * * *

cron.schedule('25 5 10 * * *', function() {
  console.log('Time for breakfast');
});
Mikko
  • 1,877
  • 1
  • 25
  • 37
  • Glad I could help – Mikko Jun 04 '17 at 12:47
  • can you tell me the error how to set username and password using mongodb client in mongodb program please..see this link. https://stackoverflow.com/questions/44352662/how-to-set-username-and-password-in-mongdb-program?noredirect=1#comment75707607_44352662 – Vignesh Ravi Jun 04 '17 at 13:00