Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 493706 - sys-fs/mdadm-3.3-r2 - cron.d entry for checkarray is incompatible with sys-process/dcron, causing error emails
Summary: sys-fs/mdadm-3.3-r2 - cron.d entry for checkarray is incompatible with sys-pr...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
Depends on:
Reported: 2013-12-09 03:48 UTC by Hank Leininger
Modified: 2014-07-12 20:28 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Hank Leininger 2013-12-09 03:48:18 UTC
sys-fs/mdadm-3.3-r2 started installing checkarray from the debian patchset, and also added an entry to /etc/cron.d/ to run it.

The format of the Debian-based mdadm.cron.d file breaks on (at least) dcron.

The file contains:

57 0 * * 0 root if [ -x /usr/sbin/checkarray ] && [ $(date +\%d) -le 7 ]; then /usr/sbin/checkarray --cron --all --idle --quiet; fi

...But in dcron, /etc/cron.d/ files are always jobs run by root, so there is no field for the username.  It looks to me like vixie cron (at least) does support the uername field in cron.d entries.

Reproducible: Always

Steps to Reproduce:
1. Use dcron as the cron daemon.
2. Upgrade to sys-fs/mdadm-3.3-r2 
3. Get error emails once a week from cron
Actual Results:  
Every week when the job runs, get this parse error email:

Date: Sun, 08 Dec 2013 00:58:01 -0500
From: root <root@box>
To: root
Subject: cron for user root root if [ -x /usr/sbin/checkarray ] && [ $(date +\%d) -le 7 ]; then /usr/sbin/checkarray --cron --all --idle --quiet; fi

/bin/sh: -c: line 0: syntax error near unexpected token `then'
/bin/sh: -c: line 0: `root if [ -x /usr/sbin/checkarray ] && [ $(date +\%d) -le 7 ]; then /usr/sbin/checkarray --cron --all --idle --quiet; fi'

Expected Results:  
The line should have parsed correctly, the if test should have executed properly, and either run or not run checkarray.

I'm not sure what the correct fix is, except perhaps recreate this one-liner as a /etc/cron.weekly/ file, because those files' format do not depend on what cron daemon is in use (they just get executed by run-crons, or run-parts, or whatever).

The /etc/cron.weekly/ file would be really really simple, and should accomplish exactly what the cron.d/ file does:


if [ -x /usr/sbin/checkarray ] && [ $(date +\%d) -le 7 ]; then
  /usr/sbin/checkarray --cron --all --idle --quiet
Comment 1 SpanKY gentoo-dev 2013-12-16 05:34:36 UTC
should be all set now in the tree; thanks for the report!

Commit message: Tweak cron.d entry to work for all crons
Comment 2 Mike Gilbert gentoo-dev 2014-07-12 20:13:12 UTC
(In reply to SpanKY from comment #1)

This broke the cron.d file for cronie (and probably vixie as well). The username field is requried in a system cron job.
Comment 3 Hank Leininger 2014-07-12 20:18:06 UTC
> This broke the cron.d file for cronie (and probably vixie as well). The
> username field is requried in a system cron job.

Argh, so different cron's have different syntaxies for /etc/cron.d/ entries?  Sigh.

Do you know if my alternate suggestion, turning it into a cron.weekly/ script, will work across those other crond's?  (Assuming most/all crons supported by Gentoo include the moving parts to run /etc/cron.weekly/ scripts.)
Comment 4 Mike Gilbert gentoo-dev 2014-07-12 20:28:04 UTC
Yes, I think cron.weekly will be fine.

+*mdadm-3.3-r4 (12 Jul 2014)
+  12 Jul 2014; Mike Gilbert <> +files/mdadm.weekly,
+  +mdadm-3.3-r4.ebuild:
+  Replace cron.d file with a cron.weekly script, disabled by default. Bug
+  493706.