Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To my surprise, my raid array entered degraded mode some time ago. How can I set up a cron job to warn me? I've tried from the mdadm man page:

mdadm --monitor --scan -1
from a cron script will ensure regular notification of any degraded arrays.

But on my array this does nothing, despite the problem:

# cat /sys/block/md0/md/degraded 
# cat /proc/mdstat 
Personalities : [linear] [multipath] [raid0] [raid1]
[raid6] [raid5] [raid4] [raid10] 
md0 : active raid1 sdc1[0]
      976759672 blocks super 1.2 [2/1] [U_]

See also: App indicator for software RAID running degraded?

share|improve this question
I haven't checked if this has changed recently, but last I looked, you did get mail, but not a notification that you got mail. See Automatic Notification of Degraded RAID Array in Ubuntu and then How are administrators supposed to read root's mail? – Gilles Oct 31 '12 at 0:35
@Gilles, you should put that in an answer. – psusi Oct 31 '12 at 1:01

Ubuntu does in fact have this cron job already (check /etc/cron.daily/mdadm). Ubuntu also installs anacron by default, so the job will be run once a day even if you shut down your computer at night.

When a cron job produces output, it is sent to the local mailbox of the user running the crontab (here, the system administrator account, root).

Unfortunately, Ubuntu does not set anything up for users to receive and read local mail. So you need to do several things:

  • Make sure your machine runs a mail transfer agent such as postfix.
  • Have root's mail forwarded to your account. All the system cron jobs run as root. With postfix, edit the file /etc/aliases and add a line like

    root: bryce

    to forward root's mail to your local mail account.

  • If you want your local email to be forwarded to an online account, create a file called .forward in your home directory containing your address, e.g. with the command

    echo >~/.forward
  • If you want to read your local mail, set up your mail reader program for that.

See How are administrators supposed to read root's mail? for more detailed and up-to-date instructions on reading local administrator mail.

share|improve this answer

Your Answer


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.