Just wanted to share a simple bash script that, given you have as many or fewer drives in your pool than days in a given month, will issue a defrag command on each drive on its corresponding day of month (i.e. 1st of the month, defrag drive 1). This is my, albeit kludgy, way of defragging every drive once per month without putting too much strain on the system. If you've got a better way, please share! **I have no evidence this will speed up a system!
#!/bin/bash
# Get the current day of the month
dom=$(date +"%-d")
# Get the drive to match
drive=/dev/md$dom
if [[ $(find $drive) ]]; then
echo "Defragging $drive"
xfs_fsr -v $drive
else
echo "No drive found at position $drive"
fi