Bug#895024: Error: bad hour; while reading /etc/crontab makes the cron do nothing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug#895024: Error: bad hour; while reading /etc/crontab makes the cron do nothing

Salvo Tomaselli-3
Package: cron
Version: 3.0pl1-130
Severity: normal
Tags: upstream

Dear Maintainer,

I had made a mistake while writing crontab, and had reversed hours and minutes.

This happened:
Error: bad hour; while reading /etc/crontab

Hoewver, cron then doesn't run any job at all. In this case it should just
terminate with error, so I would see that the service is not running at all.

Keeping running but being in an error state and doing nothing is not very
ideal, just makes it harder to find what is happening.

-- Package-specific info:
--- EDITOR:


--- /usr/bin/editor:
/usr/bin/vim.basic

--- /usr/bin/crontab:
-rwxr-sr-x 1 root crontab 39352 Mar 12 22:00 /usr/bin/crontab

--- /var/spool/cron:
drwxr-xr-x 5 root root 4096 Oct 24 09:56 /var/spool/cron

--- /var/spool/cron/crontabs:
drwx-wx--T 2 root crontab 4096 May  3  2015 /var/spool/cron/crontabs

--- /etc/cron.d:
drwxr-xr-x 2 root root 4096 Mar 19 10:32 /etc/cron.d

--- /etc/cron.daily:
drwxr-xr-x 2 root root 4096 Mar 27 09:50 /etc/cron.daily

--- /etc/cron.hourly:
drwxr-xr-x 2 root root 4096 Mar 19 10:32 /etc/cron.hourly

--- /etc/cron.monthly:
drwxr-xr-x 2 root root 4096 Mar 19 10:32 /etc/cron.monthly

--- /etc/cron.weekly:
drwxr-xr-x 2 root root 4096 Mar 19 10:32 /etc/cron.weekly


-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.15.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to it_IT.UTF-8), LANGUAGE=it (charmap=UTF-8) (ignored: LC_ALL set to it_IT.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages cron depends on:
ii  adduser         3.117
ii  debianutils     4.8.4
ii  dpkg            1.19.0.5
ii  libc6           2.27-3
ii  libpam-runtime  1.1.8-3.7
ii  libpam0g        1.1.8-3.7
ii  libselinux1     2.7-2+b2
ii  lsb-base        9.20170808

Versions of packages cron recommends:
ii  postfix [mail-transport-agent]  3.3.0-1

Versions of packages cron suggests:
pn  anacron        <none>
pn  checksecurity  <none>
ii  logrotate      3.11.0-0.1

Versions of packages cron is related to:
pn  libnss-ldap   <none>
pn  libnss-ldapd  <none>
pn  libpam-ldap   <none>
pn  libpam-mount  <none>
pn  nis           <none>
pn  nscd          <none>

-- Configuration Files:
/etc/crontab changed [not included]

-- no debconf information

Reply | Threaded
Open this post in threaded view
|

Bug#895024: Error: bad hour; while reading /etc/crontab makes the cron do nothing

Christian Kastner-3
Tags: + unreproducible moreinfo

Hi Salvo,

On 2018-06-04 12:57:37 Salvo Tomaselli wrote:
> I had made a mistake while writing crontab, and had reversed hours and minutes.
>
> This happened:
> Error: bad hour; while reading /etc/crontab
>
> Hoewver, cron then doesn't run any job at all. In this case it should just
> terminate with error, so I would see that the service is not running at all.

The service should be running. The cron daemon just skips the broken
crontab.

I just tested this by first creating a valid crontab

  * * * * * root date >> /tmp/datestamp

and later by adding an invalid one

  * 25 * * * root date >> /tmp/foostamp

and the following is logged to the cron facility:

    Mar  3 18:58:01 devel CRON[22663]: (root) CMD (date >> /tmp/datestamp)
    Mar  3 18:59:01 devel CRON[22721]: (root) CMD (date >> /tmp/datestamp)
    Mar  3 19:00:01 devel cron[3870]: Error: bad hour; while reading /etc/cron.d/bar
    Mar  3 19:00:01 devel cron[3870]: (*system*bar) ERROR (Syntax error, this crontab file will be ignored)
    Mar  3 19:00:01 devel CRON[22751]: (root) CMD (date >> /tmp/datestamp)
    Mar  3 19:01:01 devel CRON[22755]: (root) CMD (date >> /tmp/datestamp)

As you can see, the crontab /etc/cron.d/bar is skipped because of a
syntax error, but cron continues executing the other crontab.

Could you please re-check if cron is indeed not processing any other
tabs (for example, with the above examples).

Note that I have enabled logging for every priority of the cron
facility to /var/log/cron.log (/etc/rsyslog.conf has a commented-
out example for this).

Regards,
Christian