Crontab - missing newline before EOF

By: Shane Harter|Last Updated: Oct 09, 2026

A POSIX text file ends every line, including the last one, with a newline. vim and nano add that character when you save. cron expects it.

What causes this error

The last line of your crontab does not end with a newline character.

You usually hit this when a script writes the crontab and forgets the final newline, or strips it. On Debian and Ubuntu, crontab refuses the file and prints:

new crontab file is missing newline before EOF, can't install.

The previous crontab is not replaced. That is the only error line. With crontab -e, Debian also prints crontab: installing new crontab before it, and then Do you want to retry the same edit? (y/n). Answer y and the editor opens again. crontab /path/to/file prints only the error.

cronie (Red Hat, Fedora, and cronie installed elsewhere) does not print the Debian sentence. crontab refuses the file. The first line quotes the file and the line that was cut off:

"/home/user/jobs.cron":4: premature EOF
errors in crontab file, can't install.

On RHEL 8 the second line is errors in crontab file, can't install., as in the example. On RHEL 9 and current Fedora that line is Invalid crontab file, can't install. With crontab -e the quoted path is cronie's temporary file, named like /tmp/crontab.XXXXXX, and cronie prints crontab: installing new crontab before the error, then asks if you want to retry the same edit.

Installing through crontab is what refuses the file. If a copy missing that newline is already in the spool, the daemon still has to load it. On RHEL 8 it does not log missing newline before EOF. It runs the earlier lines and skips the line that was cut off. On RHEL 9 and current Fedora it logs missing newline before EOF, runs the earlier lines, and skips the cut-off line. On Debian and Ubuntu the daemon logs Missing newline before EOF, this crontab file will be ignored and runs none of the jobs in that file. A different problem on a numbered line, such as bad minute, is Errors in crontab file, can't install.

Fixing missing newline before EOF errors

In crontab -e, go to the end of the file and press Enter so a blank line follows the last job, then save.

If a script writes a file you install with crontab /path/to/crontab, append a newline before installing it. Do not edit the live spool file under /var/spool/cron by hand.

echo >> /path/to/crontab
crontab /path/to/crontab

echo with no arguments writes one newline. If the generator keeps dropping it, fix the generator so every write ends in \n.

Want alerts if your cron jobs stop working?

Monitor your cron jobs with Cronitor to easily collect output, capture errors and alert you when something goes wrong.