Migrating from crontab: five everyday schedules, translated into Kairos
If you arrived from the Kairos 1.0 announcement , this is the hands-on one: take a crontab you already have and translate it. First, the honest part: if your jobs are plain fixed-time repeats, stay on cron. "Every hour", "3am daily" — there is nothing to gain from rewriting them. You reach for a schedule language when you hit one of these: "end of month" won't fit; "business day" won't fit; the…
Migrating from cron schedules to Kairos involves translating existing crontab schedules into Kairos' schedule language. This process is beneficial when dealing with schedules that don't fit cron's fixed-time repeats, such as end-of-month, business day, or when a job started at the wrong hour due to a server move. The examples use 2026 US federal holidays as the premise, which remain constant throughout the migration.
To migrate, first define the calendar system and time zone, then create schedules using Kairos' language. For example, to run a job every weekday at 9am, use `bizDay | at(T09:00)`. For business days, exclude weekends and holidays using `bizDay = everyDay \ (satSun | holidays2026)`. Payroll runs on the 25th, or the previous business day if it falls on a weekend or holiday, can be achieved with `roll(Preceding, on: bizDay)`.
The last business day of the month can be found with `bizDay | within(month) | last`. Finally, to run three business days before month-end, use `monthEnd | roll(Preceding, on: bizDay) | shift(-3, unit: bizDay)`.
To run the translated schedules, keep one crontab line and use Kairos to determine if a point exists for the current day. For example, `0 9 * * * cd /srv/batch && ./run-if-today.sh payday.kairos ./payday.sh` checks if there's a point for the current day and runs the job if so. This allows cron to handle timekeeping while Kairos makes scheduling decisions.
Another approach is to schedule each point individually using Kairos' `next` command, which returns the next point in wall-clock text and epoch milliseconds. This can be used with OS timers to run jobs at specific times.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.