Scripts and cron
smartdisk check
Section titled “smartdisk check”Prints one line per disk and exits with the worst rating: 0 GOOD, 4 CAUTION, 3 BAD. Disks
without SMART data are listed as UNKNOWN and do not change the exit code.
-q prints only disks that are not GOOD, so a cron job stays silent while everything is fine:
smartdisk check -q || echo "a disk needs attention"smartdisk watch
Section titled “smartdisk watch”Checks again and again (-every 30m, at least 1 minute) and prints a line when a disk gets worse:
- a lower rating,
- more reallocated, pending or uncorrectable sectors,
- transfer or media errors,
- a temperature at its limit: 55 °C for hard disks, 70 °C otherwise, or the drive’s own lower maximum.
Improvements are not reported.
-exec runs a command with sh for each such disk, with the disk, its name and what changed as
$1, $2 and $3:
smartdisk watch -exec 'osascript -e "display notification \"$3\" with title \"$2\""'USB disks on a Mac
Section titled “USB disks on a Mac”Both commands read SMART the normal macOS way. With -usb (and sudo), USB disks that support it
are read over USB instead, which briefly ejects them on every check.
SmartDisk for Mac has the same checks built in, with notifications. See Monitoring and menu bar.