'Issue while sending messages on WhatsApp at specific time everyday using Node.js

I'm writing a program in Node.js which sends a WhatsApp template every day at a specific time. I used node-cron and setInterval. When I deployed the program on https://dashboard.render.com/# or https://id.heroku.com/login to run it remotely it doesn't work. but when I run it locally on VSCode it works fine, I can't seem to figure out the issue.

Help is appreciated.

const express = require('express');
const webApp = express();

webApp.use(express.json());
const PORT = process.env.PORT;
function myFunc() {
    // console.log("Checking every 2 second")
    cron.schedule('15 16 * * *', () => {
        console.log("Checking every 2 second")
        sendDayTemplate();

    })
}
setTimeout(myFunc, 1000);

webApp.listen(PORT, () => {
    console.log(`Server is up and running at ${PORT}`);
});


Heroku logs Render logs



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source