hello, it became necessary to use kroon for my site, I hadn’t dealt with it before, so I’m pretty bad at it

Somehow I managed to configure crontab to run a get request for a php file every minute

here's the code itself

SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # 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 */1 * * * * root wget -O - -q -t 1 'https://mysite.com/core/common.php?query' 

but the essence of the problem is that the task is executed only if the code looks like this:

  SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # 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 */1 * * * * root wget -O - -q -t 1 'https://mysite.com/core/common.php?query' * * * * * user-name command to be executed 

that is, if in addition to the first line, there is still some kind of line (even if it is empty), then everything works, if 1 task is not, and there are no errors in the crown logs, what kind of nonsense? thank

  • tried to just add an empty line? - KoVadim
  • @KoVadim yes, it works with an empty line too, but if it isn’t there either, I ’m not so idiotic - turik97
  • one
    @ turik97, no idiocy, but just a wry editor that incorrectly saves a file without adding the lf character to the end of the file ( line feed , it’s also \n , the hexadecimal value is 0a ) - aleksandr barakin

2 answers 2

TL; DR: This is not a bug, but a feature (c)

In the crontab (5) manual, we find:

cron requires a new line character. Crontab is missing a newline (i.e. terminated by EOF), cron will (at least partially) broken. A warning will be written to syslog.

Which means that each entry in the crontab file must end with a newline character, incl. and last. Otherwise, cron ignores it and writes a warning to the system log. You can read it with the command tail /var/log/syslog .

It is worth noting that the crontab parser used in systemd is devoid of such a problem.

  • Here I agree with the original parser! - 0andriy

Wikipedia quote :

Last line
Even in modern editions of UNIX and Linux OS, the absence of a line break at the end of the system configuration files leads to the fact that the last line is not taken into account, and the seemingly correctly composed file does not work, appearing to be a puzzle for the user not warned about this distinctive feature.

“Normal” editors always insert the lf character ( line feed , it \n , hexadecimal value 0a ) at the end of the file.

if you are not sure of the editor you are using (in particular, for example, if you use some web interface instead of the editor to edit a file), insert this symbol with your hands: move the cursor to the end of the last line and press enter .