Saltar al contenido ForoHackers

The cron job that ran twice on the night the clocks changed

Administración de sistemas
#999 · anónimo · · Denunciar

be me, sysadmin, Sunday morning in March clocks go forward at 02:00 cron job scheduled for 02:30 "monthly reports" that hour does not exist today cron, being clever, runs it at 03:00 or does it? depends on the version in October the opposite: 02:30 happens twice it ran twice customers received two reports the customers found out before I did

The server was in local time because "that is how it was installed". The fix is boring: run servers in UTC, schedule jobs at a time that never falls in the missing or repeated hour, and make the job itself idempotent, so running twice does no harm.

#1381 · anónimo · · Denunciar

Idempotency is the real answer. A key like report-2024-03-customer-123 with a unique constraint means the second run inserts nothing. The clock only exposed the missing safety net.

#1382 · anónimo · · Denunciar

Cron implementations differ, so "depends on the version" is correct. Anything that must run exactly once should not trust the scheduler to guarantee it. Treat it as "at least once" and design for that.

Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder