Fixing A “Bad Minute” Error Message When Trying To Use Crontab With Certain Unix Text Editors
A helpful tidbit I ran across about using crontab and trying to edit it using the command crontab -e.
If your cron jobs do not appear as a single line in the crontab text file, you’ll get an error like this:
"/tmp/crontab.XXXXXX.crontab":1: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit?
Crontab delimits jobs in its text file by using line breaks (newlines). Each job occupies one line. Therefore, if crontab sees anything other than an integer in the first column of a line, it throws the “bad minute” error, since the minute argument is the first one crontab encounters.
This problem most often occurs because you’re using a text editor, such as pico, that fakes word wrapping by adding a newline when it reaches a certain column position.
For example, I use pico to edit text in Linux because I find the vi text editor “very irritating.”
However, if you get close to the right margin of a document in pico, the editor will break for a new line. That’s OK if you want something to be human-readable, but it’s not OK if you are trying to put the whole job on one line, like crontab requires [click the thumbnail for full-size image]:
As you can see from the screenshot above, this fairly long crontab command is converted into three lines of text by pico. Crontab will see the first line and not have a problem with it. But it will see line 2 — which is actually a switch for our perl script — and throw the “bad minute” error, because “-config=example.com” is not an integer.
The simple fix is to go to delete the line breaks, which you can most easily do by putting your cursor on the first character of each bad newline and hit the backspace key until that bad newline is joined back up with line 1. [click thumbnail for full-size image]































Leave a comment