~/selfhostkit.dev

selfhostkit.dev · tools

cron expression

Type a crontab schedule, read it in plain english, check when it fires next. Everything runs in your browser.

next runs · your local time
    crontab line
     

    The 5 fields

    ┌───────── minute        0-59
    │ ┌─────── hour          0-23
    │ │ ┌───── day of month  1-31
    │ │ │ ┌─── month         1-12 or jan-dec
    │ │ │ │ ┌─ day of week   0-7 or sun-sat (0 and 7 are both sunday)
    │ │ │ │ │
    * * * * *  command

    * means every value, , makes a list (1,15), - a range (1-5), / a step (*/10). Shortcuts: @hourly, @daily, @weekly, @monthly, @yearly, @reboot.

    The traps I keep seeing

    Day of month AND day of week. If you restrict both, cron fires when either matches. 0 12 13 * 5 is not "Friday the 13th", it's "every 13th and every Friday". The tool tells you when that happens.

    6 fields. Quartz, Spring or some CI tools add a seconds field. Plain crontab has 5. Paste a 6-field expression here and you get told.

    Timezone. cron runs in the server's timezone, not yours. On a VPS that's often UTC. I run all my jobs on a Hetzner box in UTC, so a "4 AM" backup is 6 AM in Paris in summer. Check with timedatectl.

    Silent failures. cron has a minimal PATH and no shell profile. Use absolute paths and log the output, or you'll never know it broke:

    0 4 * * * /usr/bin/python3 /home/me/scripts/backup.py >> /home/me/logs/backup.log 2>&1

    Edit your jobs with crontab -e, list them with crontab -l. Running a service in Docker instead? Turn your docker run into compose with the converter and check the file with the YAML validator.

    ← all tools