errors in crontab file, can't install.
By Jake Marsh · Updated
The error
Terminal output after saving crontab -e, usually with a line like "/tmp/crontab.XXXX":1: bad minute just above it.
Quick fix
- Answer y to "Do you want to retry the same edit?" and look at the line number in the message.
- Check that the line has exactly five time fields before the command: minute, hour, day of month, month, day of week.
- Paste the five fields into the cron expression explainer to see which one is invalid and when the schedule would run.
Why this happens
cron validates every line when you save. "bad minute", "bad hour" and similar mean that field has a value out of range (minute 0-59, hour 0-23, day 1-31, month 1-12, weekday 0-7) or a stray character, often a sixth field copied from a seconds-based format such as Quartz or node-cron.
Other solutions
- Environment variables (FOO=bar) are allowed on their own lines, but a missing field on a job line shifts everything left and fails.
- If the job is only a curl call to a URL, a hosted scheduler avoids editing crontab on a server at all.
Check a schedule before you deploy it: the cron expression explainer shows the next 10 run times.
Frequently asked questions
What do "bad minute" and "bad hour" mean in crontab?
The first field on that line is not a valid minute: a number outside 0 to 59, a stray character, or a missing field that shifted the hour into the minute position. "bad hour", "bad day-of-month" and "bad day-of-week" point at the other fields the same way.
Can a crontab line have a seconds field?
No. Linux crontab uses five time fields. Six-field expressions with seconds come from Quartz, node-cron and similar libraries and fail when pasted into crontab.
Why does a % sign break my crontab line?
In crontab an unescaped % ends the command and turns the rest into standard input. Write \% instead, for example date +\%Y-\%m-\%d.
Can crontab run a job on the last day of the month?
Not with a single field value: crontab does not accept L. Run on days 28 to 31 and check that tomorrow is the 1st, or use a scheduler that supports L, such as RunLater (0 9 L * *).
Have the URL called on schedule, with retries
RunLater calls your URL on a cron schedule or at an exact time, in your timezone, retries failed calls with backoff and logs each response, so a timeout or a 5xx shows up in a log instead of disappearing.