2

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?

2

1 Answer 1

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 [email protected] >~/.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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .