I am using node cron to run the cron every last day of the month
var job = new CronJob('01 01 12 * * *', function() {
    //my function to do job
 }, function () {
 }, true);
so what time I should set so that the script run every last day of the month
The simplest method actually to run the cron at 00:01 the next day of the month, and to use
0 0 1 * *But if you insist on running it on the last day you will need to check in your script.
Use the following js snippet;
const today = new Date();
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
if (today.getMonth() !== tomorrow.getMonth()) {
  // run your cron job
}
so you can program your cron to run daily but the if will guard to execute it only when it is the last day of the month.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With