Reliable HTTP cron and delayed-job scheduling with automatic retries and full run logs — delay.run

You run crontab -e, add a line, save, and get this:

crontab: installing new crontab "/tmp/crontab.Yb3kQ2/crontab":4: bad minute errors in crontab file, can't install. Do you want to retry the same edit? (y/n) 

The good news: cron told you the line number (:4) and the field it didn't like. The bad news: the error messages are terse, and some of the worst crontab mistakes don't produce an error at all.

This post covers both.

Reading the error

The format is "<temp file>":<line>: <problem>. The line number counts every line in the file, including comments and blank lines. Answer y to reopen the editor with your changes intact, go to that line, and fix the field named in the message.

Cron lines have five time fields, then the command:

# ┌ 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 Sunday) # │ │ │ │ │ 30 2 * * 1-5 /usr/local/bin/backup.sh 

The common messages

bad minute, bad hour, bad day-of-month, bad month, bad day-of-week: a value in that field is out of range or uses syntax cron doesn't know. Typical causes:

  • Out of range: 60 minutes, 24 hours, 32 days. Midnight is 0, not 24.
  • Unsupported characters: L (last day), W (weekday), # (nth weekday), ?. These come from Quartz and some cloud schedulers. Standard cron doesn't support them.
  • Mixed names and numbers in a range in ways your cron doesn't accept, or names in a step expression. mon-fri is fine; something like mon-5 is risky. Stick to one style.
  • Stray spaces inside a list: 1, 15 is two fields to cron. Write 1,15.

bad command: cron found the time fields but no command after them, often because the line has only five fields. Also appears when a line was split across two lines by the editor or a copy-paste.

premature EOF or missing newline before EOF: the last line of the file doesn't end with a newline. Some editors don't add one. Go to the end of the last line and press Enter, or add a comment line at the bottom so the last real line is never last.

bad variable or errors on lines with =: environment lines like MAILTO=ops@example.com or PATH=/usr/local/bin:/usr/bin:/bin are allowed, but not every cron version handles spaces, quotes or variable expansion the same way. PATH=$PATH:/opt/bin doesn't expand $PATH in most crons; write the full value.

The mistakes cron accepts without complaint

These are worse, because crontab -e saves happily and the job then never runs, or runs at the wrong time.

Quartz or cloud syntax with six fields.

0 0 9 * * ? /usr/local/bin/report.sh 

This is "9 a.m. every day" in Quartz (seconds first). Standard cron reads 0 0 9 * * as "midnight on the 9th of every month", and the command as ? /usr/local/bin/report.sh, which fails at runtime. No install error.

Unescaped % signs. In a crontab, % in the command means "newline", and everything after the first % is sent to the command's standard input. This classic breaks silently:

0 3 * * * tar czf /backups/site-$(date +%F).tgz /var/www 

Escape it as \%, or move the command into a script.

Day-of-month and day-of-week together. 0 9 1 * 1 doesn't mean "the 1st, if it's a Monday". When both fields are restricted, cron runs when either matches: every Monday and the 1st of every month.

User field in the wrong place. Files in /etc/cron.d/ and /etc/crontab have an extra field, the user, between the schedule and the command:

30 2 * * * root /usr/local/bin/backup.sh 

Forget it there and cron tries to run as a user named /usr/local/bin/backup.sh. Add it in a personal crontab (crontab -e) and cron tries to run a command called root. Neither file is validated the way crontab -e validates, so you only find out from the logs.

Files in /etc/cron.d/ with the wrong name or permissions. Many cron implementations ignore files in cron.d whose names contain a dot (so backup.cron is silently skipped), and files that are group- or world-writable. Name them backup, owned by root, mode 0644.

The worst crontab bugs install cleanly and fail at 3 a.m. delay.run runs the job on an explicit schedule as an HTTP call, retries a failed run, and keeps a log of every attempt, so “did it run?” has an answer.

Check your crontab before it bites

A few habits that catch these early:

  1. Validate before installing. Keep the crontab in version control and install it with crontab file.txt. The same validation runs, and a CI step can run it in a container on every change.
  2. Preview the schedule. Paste the five fields into a cron expression explainer, or use a library like croniter (Python) or cron-parser (Node) to print the next five run times:
from croniter import croniter from datetime import datetime it = croniter("0 9 1 * 1", datetime(2026, 11, 16)) print([it.get_next(datetime).strftime("%a %d %b %H:%M") for _ in range(5)]) 
  1. Log every run. Redirect output somewhere you'll read: >> /var/log/jobs/backup.log 2>&1. Then check the cron log (grep CRON /var/log/syslog on Debian and Ubuntu, journalctl -u cron or -u crond elsewhere) for the line where cron started the command.
  2. Put the logic in a script. One short line in the crontab calling a script avoids almost every %, quoting and PATH surprise.

Related reading

Which crontab mistake has cost you the most time? For me it was a % in a date command that turned a nightly backup into a no-op for a month.