cron ignoring last \n character in crontab file (apparently)

Bug #1564611 reported by Lon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cron (Ubuntu)
New
Undecided
Unassigned

Bug Description

Hello,

I posted this on launchpad Q&A and basically got the answer "if there is in fact a linefeed character at the end of the last line then file a bug" answer. Here is the question I posted:

I'm trying to understand why cron is refusing to work with a certain cron 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:

<start>
# 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$
</end>

Noting that the "$"character indicates a LF (vim unix format) character. Case in point, if I search for \n then I get a match at the end of the last line. I also verified the fileformat using :set ff? which output "fileformat=unix" in vim.

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.

Thanks in advance for your time!

Tags: bot-comment
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1564611/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Lon (lon-sun)
affects: ubuntu → cron (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.