node-cron
node-cron copied to clipboard
Command running twice
So this is my code:
const schedule = require('node-cron')
schedule.schedule('*/41 * 6-20 * * *',()=>{
console.log('Ran a command @ ', new Date().toString())
})
I am trying to run the command between 6:00 to 20:00 everyday on an interval of 41 seconds but it runs twice in a minute

How can I fix it?
I am not affiliates with this lib, but can help you out anyways :)
This is actually how cron is supposed to work. */41 will trigger at 0 and 41. Just as 0/5 always trigger at 0,5,10,15 etc.
See https://github.com/Hexagon/croner/issues/52 for an alternative solution while still using standard cron. This specific issue is absolut months, but could with some simplification be converted to seconds.