Next.js Discord

Discord Forum

Cron Job not deployable

Answered
Cape lion posted this in #help-forum
Open in Discord
Avatar
Cape lionOP
//vercel.json in root folder
{
  "buildCommand": "pnpm turbo build",
  "ignoreCommand": "pnpm dlx turbo-ignore",
  "crons": [
    {
      "path": "/api/cron",
      "schedule": "*/5 * * * *"
    }
  ]
}


//app/api/cron/route.ts
import { NextRequest, NextResponse } from "next/server";

export const config = {
  runtime: "edge",
};

export default async function handler(req: NextRequest) {
  console.log("Works :D");
  return new NextResponse(null, {
    status: 200,
  });
}


When I push these two changes up to my GitHub I get deployment failed for that project that has this cron job (see image). I can't click the details button because it has not deployed anything to Vercel. Why does this happen? I am using Turbo repo and followed the official documentation.

Heck, even looked at the example here https://github.com/vercel/examples/tree/main/solutions/cron
Image
Answered by Cape lion
So.. to anyone having the same issue it is due to you being on a Hobby plan and setting the schedule to e.g. "schedule": "*/5 * * * *" which is every 5th minute but the docs states that on a Hobby plan you can only run the cron job once per day. Changing it to "schedule": "0 1 * * *" which is at 1 AM works.
View full answer

11 Replies

Avatar
Cape lionOP
If it is this stupid limitation of the scheduled cron job is triggered once per day I'll be miserable... https://vercel.com/docs/cron-jobs/usage-and-pricing#usage-&-pricing-for-cron-jobs
Avatar
Go read the error message in the deploy log on Vercel. It should tell you what’s wrong.
Avatar
Cape lionOP
Where do I find the deploy log on Vercel?
I only see Build and Runtime logs
Avatar
Uh go to your Vercel account and go to the project and see it there?
Each deployment has a log
Avatar
Cape lionOP
Yes, but as I wrote in the original post I don't see a deployment when I pushed those two changes to GitHub (which eventually pushes the changes to Vercel and creating a new deployment)
Avatar
So it’s not being deployed to your Vercel account? Whose Vercel account is it?
Avatar
Cape lionOP
So.. to anyone having the same issue it is due to you being on a Hobby plan and setting the schedule to e.g. "schedule": "*/5 * * * *" which is every 5th minute but the docs states that on a Hobby plan you can only run the cron job once per day. Changing it to "schedule": "0 1 * * *" which is at 1 AM works.
Answer
Avatar
Cape lionOP
It is mine. Deployments work but didn't deploy (read my message above)