I wanted to share a quick script I put together to manage stopping age_mover when I need to take down the array. I found myself defaulting to the stop command as that's what the base unraid mover uses and what I wanted was a way to attempt a soft stop with a timeout without having to monitor it. #!/bin/bash
TIMEOUT=60 # Set the timeout duration in seconds
END_TIME=$((SECONDS + TIMEOUT))
echo "Starting loop with a ${TIMEOUT} second timeout to wait for mover to stop"
echo "Sending mover sofstop command"
MOVERSTATUS=$(age_mover softstop | grep "running")
while [ $SECONDS -lt $END_TIME ]; do
MOVERSTATUS=$(age_mover status | grep "running")
if [ "$MOVERSTATUS" = "mover: not running" ]; then
echo "Mover soft stopped in $SECONDS seconds"
break
fi
sleep 1
echo "Current time: $SECONDS seconds elapsed"
done
if [ $SECONDS -ge $END_TIME ]; then
echo "Timeout reached after $TIMEOUT seconds"
echo "Sending mover hard stop command"
age_mover stop
fiI'm very open to any ideas to improve on this. The script doesn't run frequently and I know doing grep on the text of a command's output is a fragile way to test, but the age_mover commands seem to reliably either say "mover: running" or "mover: not running" so it's working for now.