Home / Companies / Strapi / Blog / Post Details
Content Deep Dive

Cron Jobs in Strapi 5: A Complete Guide

Blog post from Strapi

Post Details
Company
Date Published
Author
Theodore Kelechukwu Onyejiaku
Word Count
5,588
Company Posts That Month
3
Language
English
Hacker News Points
-
Post removed?
No
Summary

Strapi 5 cron jobs enable backend code to run automatically on schedules for tasks such as sending newsletters, synchronizing APIs, publishing scheduled content, and removing expired records. Cron is disabled by default and must be enabled in the server configuration, with static tasks commonly organized in a dedicated cron-tasks file or registered dynamically through `strapi.cron.add()` during application or plugin bootstrap. The recommended task format uses named object entries containing a task callback and scheduling options, as expression-keyed tasks are anonymous and cannot be removed easily. Strapi uses node-schedule, supports five- or six-field cron expressions and optional time zones, but its scheduler is stateless across restarts and executes every job on each application instance in a scaled deployment. Tasks can access Strapi’s Document Service API to work with single or collection content types, while dynamically registered jobs should be removed during shutdown or before rescheduling. The guidance emphasizes database locks, external schedulers, or a dedicated cron instance to prevent duplicate execution across multiple servers, as well as logging, error handling, environment-specific schedules, and idempotency protections. For complex workloads requiring retries, queues, monitoring, job history, or isolation from the API process, external tools such as BullMQ, Agenda, or cloud schedulers may be more appropriate.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.