Documentation

Cron Jobs

Learn how to use cron jobs in Dirstarter to automate tasks

Dirstarter recommends hosting your project on Vercel for the best experience. We provide a pre-configured cron job for publishing tools on schedule. Vercel offers up to 2 cron jobs running in the Hobby plan (free tier) and 40 jobs per month in the Pro plan.

It is by far the easiest way to set up automated publishing on schedule, but you can also use any other cron job service you want. A pretty popular, free service for cron jobs is cron-job.org.

Publish Tools Job

The publish tools job is a cron job that publishes scheduled content. It is configured to be triggered every day at midnight.

vercel.json
{
  "crons": [
    {
      "path": "/api/cron/publish",
      "schedule": "0 0 * * *" // Every day at midnight
    }
  ]
}

You can use crontab guru to generate a desired cron job schedule.

Securing the endpoint

/api/cron/publish is protected by a required CRON_SECRET. The endpoint rejects any request whose Authorization header is not Bearer <CRON_SECRET>, so set this variable before scheduling the job:

.env
CRON_SECRET="a-long-random-string"

On Vercel, scheduled requests automatically include Authorization: Bearer <CRON_SECRET> once the variable is set, so no extra setup is needed. With any other scheduler (such as cron-job.org), add the header to the request yourself.

Last updated on

On this page

Join hundreds of directory builders

Build your directory, launch, earn

Don't waste time on Stripe subscriptions or designing a pricing section. Get started today with our battle-tested stack and built-in monetization features.

Get Lifetime Access