I have configured one cron job in my Vercel Hobby Plan project. Despite setting them to run every day at 15 PM UTC and reviewing existing GitHub discussions, the job isn’t executing as expected. I need assistance in troubleshooting and resolving this issue.
Created a Next.js project and deployed it to Vercel.
Added the above cron configuration to the project’s vercel.json file.
Implemented the corresponding API routes:
/api/cron
Deployed the project to Vercel using the Hobby Plan.
Waited for the cron jobs to execute (expected every day at 15 pm).
Checked Vercel logs and monitored the application, but no cron job executions were observed. Also, no LOGS where present regarding the execution of the cron jobs
OBS: My cronjob files are in the correct folder: scr/app/api/cron and the name of the file is route.ts
When I executed the cronjob through the URL it was correctly returning what I expected
What could be pottentially conflicting configurations?
Where can I create a Cronjob through Vercel’s interface?
Other than that I’d like to discuss a bug that might have been caused by this configuration:
Apparently the configuration wasn’t working, because I wasn’t getting any logs on Vercel’s interface and had no register of the execution of the CronJobs.
However, my clients received emails - even without me triggering the endpoint - on the exact time period that I had defined on the CronJob.
Objectively: I set up my cronjob to send emails everyday at 15. However, it not only doesn’t work daily, apparently it works only on SOME DAYS and it’s calling the same cronjob multiple times.
For example, today: my clients received emails at 15:20, 15:22, 15:23 and some of them just got send at 17:52, 17:55, etc. Could you try to help me with this? Do you have a bug that causes the cronjobs to be triggered multiple times a day? And to not be consistent, triggering only some days and other not?
I’m not aware of any other reports of other experiencing this behavior. One thing that I have seen cause similar problems is the difference between UTC and local time. Since the server uses UTC time, it’s important to make sure the cron schedule is set for the UTC time corresponding to the local time when you actually want the function to run. Otherwise it will run at a different time than you expect.
Just to be sure, I deployed my own example project. I created a new repo using npx create-next-app@latest, added an /api/hello function, and set the cron schedule to run once per day. Then I triggered the cron job manually and checked the logs. I had to refresh the logs page for the production deployment, but it did appear there shortly after I clicked the “Run” button.