Cron to Queue Migration on Lightsail Without Dropped Jobs

Moving from cron scripts to queue workers improves reliability, but migration can lose jobs if cutover is rushed. Use dual-write and reconciliation for a safe switch.

Step 1: introduce queue producer while cron still runs

./legacy-cron.sh --emit-queue --emit-legacy

Step 2: add idempotency key to both execution paths

idem_key = date + job_type + entity_id

Step 3: run reconciliation report before disabling cron path

python compare_runs.py --legacy legacy.log --queue worker.log

Pitfall

Turning off cron the moment queue starts. Hidden worker failures then create silent gaps.

Verification

  • Dual-run period shows matching outputs.
  • No duplicate side effects due to idempotency keys.
  • Cron is removed only after reconciliation passes.

Get New Tutorials by Email

No spam. Just clear, practical breakdowns you can apply right away.

Enjoy this tutorial?

Get new practical tech tutorials in your inbox.