Is the file 'crontab' need an empty line at the file end?

General support questions
Post Reply
sunweiqiang
Posts: 1
Joined: 2015/03/25 01:40:18

Is the file 'crontab' need an empty line at the file end?

Post by sunweiqiang » 2015/03/25 01:51:48

Code: Select all

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed


*/20 * * * * root vnstat -u
1,21,41 * * * * root vnstati -h -o /www/dev/vnstat/h.png
2 * * * * root vnstati -d -o /www/dev/vnstat/d.png
3 0 * * * root vnstati -m -o /www/dev/vnstat/m.png
4 0 * * * root vnstati -t -o /www/dev/vnstat/t.png
The last line never executed, is that need a empty line at the end of file?
Is that a bug?

lightman47
Posts: 1522
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Is the file 'crontab' need an empty line at the file end

Post by lightman47 » 2015/03/25 12:38:42

I don't know for sure but mine has one and works. My suspicion is that it's actually the <CR> at the end that it's looking for --- which just happens to cause a "blank line".
:) Interestingly, there are other files that DON'T work if there's a trailing <CR>. Go figure.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Is the file 'crontab' need an empty line at the file end

Post by gerald_clark » 2015/03/25 12:54:37

Linux text files do NOT have <CR> at the end of the line, and including them will make many programs not work the way you wish.
A Linux text file has a linefeed character as the line terminator.

lightman47
Posts: 1522
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Is the file 'crontab' need an empty line at the file end

Post by lightman47 » 2015/03/25 13:22:56

Thanks.

Post Reply