#!/bin/bash date=$(date -u +%Y-%m-%d--%H:%M) if sudo true then true else echo 'Root privileges required' exit 1 fi for drive in /dev/sd[a-z] /dev/sd[a-z][a-z] /dev/nvme[0-9]n[0-9] do if [[ ! -e $drive ]]; then continue ; fi echo -n "$drive " echo -e "\n" smart=$( sudo smartctl -i $drive |grep Serial sudo smartctl -A $drive |grep -E "^ "9"" |awk -F" " '{ print $2,$10 }' sudo smartctl -A $drive |grep -E "^ "5"" |awk -F" " '{ print $2,$10 }' sudo smartctl -A $drive |grep -E "Current_Pending_Sector" |awk -F" " '{ print $2,$10 }' sudo smartctl -A $drive |grep -E "Offline_Uncorrectable" |awk -F" " '{ print $2,$10 }' ) echo -e "$smart\n" >> /var/log/smart-check/smart-check$date.log done