Send Email Alert When Hardware Errors Detected

[root@instructor script]# yum install mcelog -y
Default Mcelog cron file is here /etc/cron.hourly/mcelog.cron
[root@instructor script]# vi /etc/cron.hourly/mcelog.cron


# do not run if mcelogd is running

service mcelogd status >& /dev/null

[ $? -eq 0 ] && exit 0

# is mcelog supported?

/usr/sbin/mcelog --supported >& /dev/null

if [ $? -eq 1 ]; then

       exit 1;


/usr/sbin/mcelog --ignorenodev --filter >> /var/log/mcelog 

After that paste bellow line into you file.. 
[root@instructor script]# touch
[root@instructor script]# vi


[ $(grep -c "error" /var/log/mcelog) -gt 0 ] && echo "Hardware Error Found $(hostname) @ $(date)" | 

cat /var/log/mcelog | mail -s 'H/w Error'

exit 0 
and run the script through cronjob
Note : - If your system get any hardware issue then the script will send you a mail other wise you did 
not get any email... *Only when your system detected any issue*

About Author:

I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Newer Post
Older Post


Post a Comment