Skip to content

Início / Optitravel / Core

Scheduler

Scheduler runner that dispatches due tasks into Queue.

Run

php includes/classes/Core/Scheduler/RunScheduler.php

Options:

  • --system-id=768 (optional filter)

Run every minute:

* * * * * php /var/www/html/optitravel/includes/classes/Core/Scheduler/RunScheduler.php

Expected columns in scheduler_crons:

  • id INT PK
  • name VARCHAR
  • cron_expression VARCHAR (5 fields)
  • queue_name VARCHAR
  • job_name VARCHAR
  • payload_json TEXT (JSON object)
  • max_attempts INT
  • delay_seconds INT
  • timezone VARCHAR (ex: Europe/Lisbon)
  • system_id VARCHAR NULL
  • misfire_policy ENUM('skip','fire_once','catch_up') DEFAULT 'fire_once'
  • max_running INT DEFAULT 1
  • timeout_seconds INT NULL
  • last_dispatched_at DATETIME NULL
  • enabled TINYINT(1)

misfire_policy behavior:

  • skip: runs only when current minute matches cron.
  • fire_once: if there are missed runs, enqueue only the most recent one.
  • catch_up: enqueue all missed runs since last_dispatched_at (bounded by catch-up limit).

max_running behavior:

  • 0: unlimited overlaps.
  • >=1: max number of concurrent jobs allowed for that cron.

Optional env:

  • SCHEDULER_DEFAULT_TIMEOUT_SECONDS (default 86400): fallback timeout when cron timeout is not defined.
  • SCHEDULER_MAX_CATCH_UP_SLOTS (default 120): cap of inspected missed minutes for catch-up.

Per-cron timeout override:

  • timeout_seconds > 0: timeout window for that cron.
  • timeout_seconds <= 0 or NULL: uses SCHEDULER_DEFAULT_TIMEOUT_SECONDS.

Notes:

  • This timeout controls overlap slot TTL for that cron (crash/stall safety).
  • It does not kill a running process; it only releases scheduling protection after timeout.

↑ (Última atualização: 01/10/2026)