Cluster-Safe Scheduled Tasks
Schedule recurring background routines (such as weekly inventory audits, nightly grant compliance scans, or monthly digest emails) with distributed locking to prevent duplicate runs across multi-server clusters.
“Scheduled routines execute exactly once across high-availability clusters using atomic database state locking.”
Cluster-Safe Scheduler Architecture
In multi-node production deployments, traditional cron timers can run duplicate jobs if every server node triggers at the same time. GN-Apex uses a distributed heart-beat with atomic locks:
Weekly Stock Audits
Scans product variants on a schedule and emails a structured table of low-stock items to warehouse staff.
Automated Analytics Summaries
Compiles weekly traffic metrics and financial growth summaries and dispatches them to executives.
Automated Data Janitors
Cleans up expired temporary tokens, abandoned upload links, and unverified cart records.
Manual Task Overrides
Trigger any scheduled routine immediately from the dashboard for testing with zero cron waiting.
60-Second Atomic Distributed Locking
Every minute, the scheduler evaluates active tasks due for execution:
- A server node queries tasks where
nextRunAt <= NOW(). - It executes an atomic optimistic update, advancing
nextRunAtonly if the timestamp matches its read condition. - The single node that wins the database race enqueues the job into the background queue; all other cluster nodes skip execution harmlessly.
Timezone-Aware Cron Expressions
Configure schedules using standard 5-part cron syntax with explicit timezone support:
| Parameter | Type | Requirement | Description |
|---|---|---|---|
| 0 9 * * 1 | Weekly Schedule | Optional | Runs every Monday morning at exactly 9:00 AM in the project's configured timezone. |
| 0 0 1 * * | Monthly Schedule | Optional | Runs at midnight on the first day of every month (ideal for tuition invoices and donor statements). |
| 0 17 * * 5 | Weekly Inventory | Optional | Runs every Friday at 5:00 PM to audit warehouse stock before weekend trading. |