I also used a more simple cron schedule without the timezone.I am using Free version however the server is up when the cron job should be run, so i tested it.
I also tried this set timeout code but it only works on localhost but not on render server?
"async function customScheduler() {
const targetTime = new Date();
targetTime.setHours(20, 42, 0, 0);
let timeUntilExecution = targetTime - new Date(); // Use let to allow reassignment
if (timeUntilExecution < 0) {
// If the target time has already passed for today, schedule it for the next day
targetTime.setDate(targetTime.getDate() + 1);
timeUntilExecution = targetTime - new Date();
}
Free instances go to sleep after 15 minutes of no http activity so you can’t use this method because the service might not be running - you either need to use a paid instance type or use our cron-job feature,
Thanks but as i said in OP i tried the timeout and cron schedule before 15 minuets, meaning i start server adn put the time like 5 min after server start to test the code.
It stil wont seem to run since, it doesnt console log as it does on my localhost and the code wont seem to run at all?
HTTP activity more specifically means new requests to the app from the outside world. Operations your service is currently processing are not considered when keeping a Free service awake.
It’s very likely that the service was sleeping at the time that it failed to process the request.
During those first 15 minutes yes. But the static time specification you’ve mentioned in these examples seem unlikely to be during that 15 minute window.
Depending on how that cron is set up and stored, it might be lost when the service shuts down (sleeps).