I'm trying to understand why cron is refusing to work with a certain crontab file. The manpage for crontab says:
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.
Given the following cron file:
# managed by Fabric$ $ SHELL=/bin/sh$ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin$ $ # m h dom mon dow user command$ 17 * * * * root cd / && run-parts --report /etc/cron.hourly$ 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )$ 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )$ 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )$ $ # Postgres monitoring$ * * * * * postgres cd / && /etc/cron.d/pgup.sh$ */5 * * * * postgres cd / && /etc/cron.d/aws-scripts-mon/mon-put-instance-data.pl --mem-avail --disk-space-util --disk-path=/mnt$ $ # Postgres Backup$ 00 00 * * * postgres /etc/cron.d/pgbackup.sh$
Noting that the "$"character indicates a LF (vim unix format) character.
And I receive the following error in syslog when I restart cron:
Mar 31 17:34:02 postgres-primary0 cron[30852]: (system) ERROR (Missing newline before EOF, this crontab file will be ignored)
And adding a blank line at the end of the cron file results in no error when restarting cron.
Conclusion:
As far as I can tell the last entry does end in a newline character. So it seems like crontab is not recognizing it.
Is this a bug? Maybe what was intended was that there be a newline on its own line at the end of the file, in which case the documentation is misleading. Or possibly I'm not understanding "newline" correctly in this context...Some clarification on this matter will be appreciated.