Hi
I was trying to deploy a scheduler on Netlify , so that i can perform an event once a month. While testing, it doesn’t seems to be running. Heres my code ( Schduler that starts at midnight and runs every hour after that.
const schedule = require('node-schedule');
const moment = require('moment');
const cron_expression = '* * 0/1 * * *';
exports.handler = async (event, context, callback) => {
var job = schedule.scheduleJob(cron_expression, function () {
//MY TASKS HERE
var nextInvovationTime = job.nextInvocation();
console.log("Next Invocation : ", getIndianStandartTime(nextInvovationTime.toDate()));
console.log('The answer to life, the universe, and everything is Keep Calm & Drink Beer');
});
var nextInvovationTime = job.nextInvocation();
console.log("Next Invocation : ", getIndianStandartTime(nextInvovationTime.toDate()));
return {
statusCode: 200,
body: "Schduler ON",
}
}
function getIndianStandartTime(utcTime) {
d = new Date();
nd = new Date(utcTime + (3600000 * +5.5));
return moment(nd).format("dddd, MMMM Do YYYY, h:mm:ss a")
}
Is it possible run a schduler in Netlify. So this schedule will turn on hitting the scheduler url and once its on, it shoudl do my task at specified time. Any alternatives are there ?