README > NextJS Deploy > Scheduled Tasks
โ Database Breaking Migrations
CRON tasks are managed via Dokploy's Schedules tab. Each task runs a bun script inside the application container.
| Task | Command | Schedule | Description |
|---|---|---|---|
| Cleanup Activities | bun run cron:cleanup-activities |
Weekly (Sunday 3:00 AM) | Delete expired ActivityHistory entries (90-day retention) |
- Go to Dokploy > Projects > NextjsDeploy > select your environment (e.g.,
production) - Click on your compose service
- Go to the Schedules tab
- Click Add Schedule
- Fill in the form:
| Field | Value |
|---|---|
| Service Name | nextjs (your Next.js service in the compose) |
| Task Name | Cleanup Activity History |
| Schedule | 0 3 * * 0 (every Sunday at 3:00 AM UTC) |
| Timezone | UTC (default) |
| Shell Type | Bash |
| Command | bun run cron:cleanup-activities |
| Enabled | On |
- Click Create Schedule
- The task appears in the Scheduled Tasks list
- Check the Logs tab after the first execution to confirm it ran successfully
- Expected log output:
[cron] cleanup-activities: X expired entries deleted
Run tasks manually:
bun run cron:cleanup-activities- Add the function in
scripts/cron.ts - Add a
casein theswitchblock - Add a
cron:*script inpackage.json - Create a new schedule in Dokploy
- Update this documentation
โโโโโโโโโโโโโโ minute (0-59)
โ โโโโโโโโโโโโโโ hour (0-23)
โ โ โโโโโโโโโโโโโโ day of month (1-31)
โ โ โ โโโโโโโโโโโโโโ month (1-12)
โ โ โ โ โโโโโโโโโโโโโโ day of week (0-6, Sunday=0)
โ โ โ โ โ
* * * * *
| Expression | Description |
|---|---|
0 3 * * 0 |
Every Sunday at 3:00 AM |
0 0 * * * |
Every day at midnight |
0 */6 * * * |
Every 6 hours |
0 0 1 * * |
First day of every month |
โ Database Breaking Migrations
README > NextJS Deploy > Scheduled Tasks