Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
CRON silent failure
Yesterday I edited my /etc/crontab, after that, no commands from the entire /etc/crontab were executed.
The error was mine of course, somewhere I entered
Code:
11 59 * * *
instead of
Code:
59 11 * * *
However, the problem I have is that NO commands at all from that crontab were executed after this error was entered. The crontab contains about 20 entries, the wrong entry was 4 lines from the end. After correcting the error scheduling resumed as usual.
All other cron jobs in other crontabs were executed normally.
What I think is extremely scary, is that all/etc/crontab jobs were suspended without any error message. Not in /var/log/messages, not in /var/log/syslog, no e-mails. Total silence. I didn't even miss the e-mails which reported normal crontab, some user told me something did not happen as expected.
I know Linux is extremely user friendly, at least at the point of logging and reporting errors. Is this a feature or a bug?
It seems the cron daemon at first checks the syntax of the cron jobs and if it encounters some errors, it refuses to run anything. I cannot reproduce this behaviour (using CRONIE 1.4.4, a fork of the original vixie-cron with security and configuration enhancements like the ability to use pam and SELinux, on CentOS 6.0), but at least I see the following entries in /var/log/cron:
Code:
Dec 21 10:57:01 ocean-4 crond[1570]: (*system*) RELOAD (/etc/crontab)
Dec 21 10:57:01 ocean-4 crond[1570]: (CRON) bad hour (/etc/crontab)
Dec 21 10:57:01 ocean-4 CROND[7226]: (root) CMD (date >> $HOME/cron.log.ouput 2>&1)
In this case the cron daemon notices the bad hour but it runs the other command successfully, as I can see from the newly created /cron.log.ouput file. Note that HOME in my crontab is set to /. At this point I am inclined to agree with you: maybe a bug in your cron version or an unwanted behaviour for sure.
The red code shows what is logged while the error is in the crontab file. The vpn_keepalive script is not executed, and neither is an error message entered in cron.log.
Then, at 17:12:00 I remove the error from the /etc/crontab, and the vpn_keepalive is executed again, which is shown in the blue code. Everything which runs in the red code is not in the /etc/crontab but in the other cron files. The error in /etc/crontab is in a line after a call to vpn_keepalive.
Your assumption that cron gives up immediately after reading an error seems to be right. Another incorrect issue is that of course cron logging should be enabled by default.
Since this installation is rather old, I'll check this behaviour on a new installation and file a bug report if it persists.
It could well be a an invisible ctrl char in crontab; try using vim with ':set list' to display ctrl chars.
Incidentally, '^I' is a tab & I've never seen that in a cron log file ... could be nothing to worry about
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
The problem is that cron is not logging a failure, not why the file might be invalid. The error in the file is know (invalid time) and was my fault.
I interpreted ^I as tab character as well. It seems that cron doesn't complain about that, I have seen it for many years in the syslog, and evertime I try to remember not to use tabs in cron files in vain.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.