Skip to content

Instantly share code, notes, and snippets.

@bmb
Created April 6, 2016 07:32
Show Gist options
  • Save bmb/f47f0191ca26bd72fcfe6c71a3bc25dd to your computer and use it in GitHub Desktop.
Save bmb/f47f0191ca26bd72fcfe6c71a3bc25dd to your computer and use it in GitHub Desktop.
shell script to watch for slow file syncs
#! /bin/bash
# seconds between fdatasyncs
rate=1
# report any sync drift gte to this
drift_threshold=2
while true; do
sleep ${rate}s
mark1=`date +%s`;
echo "hello disk" >> datafile
sync -d ./datafile
mark2=`date +%s`
let "drift = mark2 - mark1"
if [ $drift -ge $drift_threshold ]; then
echo sync took $drift secs
echo mark1 $(date --date=@${mark1})
echo mark2 $(date --date=@${mark2})
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment