09. Automation Engine/Cron Scheduler

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.

CLUSTER-SAFE CONCURRENCY
60s Beat
Optimistic Concurrency Lock

Scheduled routines execute exactly once across high-availability clusters using atomic database state locking.

Zero Duplicate Runs Guarantee

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:

INVENTORY / CATALOG

Weekly Stock Audits

Scans product variants on a schedule and emails a structured table of low-stock items to warehouse staff.

DIGEST / REPORTS

Automated Analytics Summaries

Compiles weekly traffic metrics and financial growth summaries and dispatches them to executives.

SANITY / HYGIENE

Automated Data Janitors

Cleans up expired temporary tokens, abandoned upload links, and unverified cart records.

CONTROL / TESTING

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:

  1. A server node queries tasks where nextRunAt <= NOW().
  2. It executes an atomic optimistic update, advancing nextRunAt only if the timestamp matches its read condition.
  3. 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:

ParameterTypeRequirementDescription
0 9 * * 1Weekly ScheduleOptionalRuns every Monday morning at exactly 9:00 AM in the project's configured timezone.
0 0 1 * *Monthly ScheduleOptionalRuns at midnight on the first day of every month (ideal for tuition invoices and donor statements).
0 17 * * 5Weekly InventoryOptionalRuns every Friday at 5:00 PM to audit warehouse stock before weekend trading.

Manual Immediate Execution

Testing Cron Routines
Need to test an email digest without waiting for Friday? Open Settings → Scheduled Tasks and click Trigger Now to enqueue the job immediately.