1. #this script will test all sata drives and put logs in logfolder.
  2.  
  3.  
  4. [ ! "$@" ] && echo "Usage: $0 type [type] [type]"
  5.  
  6. [ ! -e smart-logs ] && mkdir smart-logs
  7. [ ! -d smart-logs ] && Can not create smart-logs dir && exit 1
  8.  
  9. a=0
  10.  
  11. for t in "$@"; do
  12.  
  13.         case "$t" in
  14.                 offline)  l=error;;
  15.                 short|long)  l=selftest;;
  16.                 *) echo $t is an unrecognised test type. Skipping... && continue
  17.         esac
  18.  
  19.        for hd in  /dev/disk/by-id/ata*; do
  20.                 r=$(( $(smartctl -t $t $hd | grep 'Please wait' | awk '{print $3}') ))
  21.                 echo Check $hd - $t test in $r minutes
  22.                 [ $r -gt $a ] && a=$r
  23.        done
  24.      echo "Waiting $a minutes for all tests to complete"
  25.                 sleep $(($a))m
  26.  
  27.         for hd in /dev/disk/by-id/ata*; do
  28.                 smartctl -l $l $hd 2>&1 >> smart-logs/smart-${t}-${hd##*/}.log
  29.         done
  30.  
  31.  
  32. done
  33.  
  34. for i in {1..10}; do
  35.         sleep .01
  36.         echo -n -e \\a
  37. done
  38.  
  39. echo "All tests have completed"
  40.  

Posted by daromer at 03 Apr 2013, 09:50:45 Europe/Berlin
Language: bash