script to get hard disk health in fedora/ubuntu
First, put this in a script.
#!/bin/bash #Change as appropriate HDD=sda export sub="SmartCtl data for HDD" echo 'To: <Your Email> Sub: [Cron] $sub MIME-Version: 1.0 Content-Type: text/html Content-Disposition: inline <html><pre>' echo '<style> hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } </style> ' echo '<h2>Errors on HDD:</h2>' echo '<hr>' sudo smartctl -l error /dev/$HDD echo '<h2>Health of HDD:</h2>' echo '<hr>' sudo smartctl -H /dev/$HDD echo '<h2>Detailed info</h2>' echo '<hr>' sudo smartctl -a -d ata /dev/$HDD echo '<h2>Journalctl output for smartd</h2>' echo '<hr>' if [[ -f /etc/fedora-release ]] then journalctl -x --show-cursor -u smartd --since=yesterday else #This is for Ubuntu.. still using dmesg dmesg -T -l err,crit,alert,emerg fi echo '<h2>All Details</h2>' echo '<hr>' sudo smartctl --xall /dev/$HDD echo "Thanks for using Amit Agarwal's script" echo '</pre></html>'
and then put this in cron:
30 15 * * 5