I have a cron job setup, with the minimum value of 60 seconds, and I want the program to be able to run at second intervals i.e. whatever I set it as 60 seconds onwards.
cron.schedule('*/' + test + '0,x * * * * *', function () {
console.log('running a task every x seconds');
});
this will run every x seconds.
If you're using middleware for Node, you can add seconds as well
cron.schedule('*/' + test + '0,30 * * * * *', function () {
console.log('running a task every minute');
});
Will run every 30 seconds, i.e. on xx:00:000
and xx:30:000
Note that javascript versions have six values, and not five like native Linux Cron, meaning the sixth is for seconds, which would be the first one
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)
Full documentation on allowed values can be found in the crontab documentation