Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:

Running
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 
1
# 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
1  
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

1 Answer 1

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 bryce@mail-provider.example.com >~/.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

 
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.