Cron Job Configuration Guide
Cron jobs are an essential part of automated operations, helping you regularly execute repetitive tasks such as data synchronization, cache updates, and report generation.
This guide will introduce how to configure cron jobs on two mainstream deployment platforms, Vercel and Dokploy, enabling automated management for your site.
Preparation
Before you begin configuring cron jobs, please ensure you complete the following preparation steps:
- Generate
CRON_SECRET
CRON_SECRET is a security key used to verify the legitimacy of cron job requests and prevent unauthorized access.
Generation Methods (choose one):
Method A: Use Online Tool
- Visit https://generate-secret.vercel.app/32
- Copy the generated random string
Method B: Use Command Line (Mac/Linux)
openssl rand -base64 32After generation, add this string to your project's environment variable CRON_SECRET.
- Complete Cron Job Endpoint Implementation
The working principle of cron jobs is: the system periodically sends HTTP requests to your application, triggering pre-written endpoints that contain specific task processing logic. Therefore, before configuring cron jobs, you need to:
- Create cron job endpoints in your project (e.g.,
/api/cron/task1) - Implement specific business logic in the endpoints
- Add
CRON_SECRETverification to ensure only legitimate requests can trigger tasks
Vercel Platform Configuration
Good to know
Vercel free accounts only support creating one cron job.
Vercel uses Vercel Cron Jobs functionality to run scheduled tasks. Configuration steps are as follows:
Create or edit the vercel.json file in your project root directory:
{
"crons": [
{
"path": "/api/cron/task1",
"schedule": "0 0 * * *"
},
{
"path": "/api/cron/task2",
"schedule": "0 2 * * 1"
}
]
}Cron Expression Explanation:
0 0 * * *- Every day at 0:00 AM (UTC time)0 2 * * 1- Every Monday at 2:00 AM (UTC time)
Timezone Note: Vercel Cron uses UTC time.
After deployment, you can view the configured cron jobs in your Vercel project's Settings > Cron Jobs.
Dokploy Platform Configuration
Dokploy provides a more flexible cron job configuration approach, supporting direct creation and management in the admin panel.
Configuration steps:
- Enter the service management panel where you need to create cron jobs
- Find the Schedules tab
- Click to create a new cron job


Fill in the form as follows:
- Task Name: Custom task name
- Schedule: Cron expression, e.g.,
0 0 * * *(execute daily at midnight) - Shell Type: Select Sh
- Command:
wget --header="Authorization: Bearer <CRON_SECRET generated in previous step>" --post-data="" -O- https://<your domain>/api/<cron job endpoint path>
After deploying the code, if you want to test the cron job, you can click the execute button on the panel to run it immediately.

Cron Expression Reference
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6) (Sunday=0)
│ │ │ │ │
* * * * *Examples:
0 2 * * *- Daily at 2:00 AM0 2 * * 1- Every Monday at 2:00 AM0 */6 * * *- Every 6 hours0 0 1 * *- 1st day of every month at 0:00 AM