Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got an Ubuntu 8.04 server using mdadm to create several RAID1 arrays. I created /etc/cron.hourly/mdadm as follows:

#! /bin/sh

set -e

mdadm --monitor /dev/md0 /dev/md3 /dev/md4 --oneshot

(Yes, the array numbers are not sequential, and I'm not using --scan beacuse I have a degraded array that may or may not have been used as swap and I can't delete, but I think that's a separate issue. If it's the underlying cause of this, I need to fix it.)

mdadm sends me email (configured in the /etc/mdadm/mdadm.conf) on DegradedArray etc. events. This is the desired behaviour. What is not desired, and I can't work out, is why cron is sending me (relatively pointless) emails, via an alias in /etc/aliases:

From: root@<hostname> (Cron Daemon)
To: root@<hostname>
Subject: Cron <root@<hostname>>    cd / && run-parts --report /etc/cron.hourly
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
Message-Id: <id@hostname>
Date: Fri,  7 May 2010 13:17:01 +0930 (CST)

/etc/cron.hourly/mdadm:
mdadm: Monitor using email address "<root_alias@domain>" from config file

I've got a dozen other servers behaving correctly (mdadm sends email, cron doesnt') with identical /etc/crontab files:

# /etc/crontab: system-wide crontab
# <snip comments>

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
<snip anacron jobs>

Should I simply remove the --report, or is there something else in my cron config somewhere causing this?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Cron will email when a job produces output on stdout or stderr. redirecting these to /dev/null is the usual way of avoiding this.

The --report arguement to run-parts prints the script name before the job's output. In this case it adds /etc/cron.hourly/mdadm: to your email ahead of the output from mdadm. Removing it will shorten the emails by removing some useful information, but not prevent them being sent.

share|improve this answer
    
Ah, got it. Because I'm not using --scan, it prints the "using email address from config file" message. Thanks! –  Andrew May 7 '10 at 5:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.