The POSIX standard requires a trailing newline character on every line of a text file. Text editors like
vim add this automatically, and cron expects it.
What causes this error
The last line of your crontab does not end with a newline character.
Because the newline character is added automatically by many text editors, if you are encountering this error it's possible your crontab file is parsed or generated by an automated process that failed to insert the newline or mistakenly stripped it from the end of your file.
Here is an excerpt from the cron manual explaining this requirement:
Cron requires that each entry in a crontab end in a newline character. If the last entry in a crontab is missing the newline, cron will consider the crontab (at least partially) broken and refuse to install it.
Fixing missing newline before EOF errors
Correct this error simply by adding a blank line at the end of your crontab. If your crontab is generated automatically, review the generation process to ensure trailing newline characters are always added and are not incorrectly stripped.
Want alerts if you cron jobs stop working?
Monitor your cron jobs with Cronitor to easily collect output, capture errors and alert you when something goes wrong.