Skip to content

Instantly share code, notes, and snippets.

@steverobbins
Last active August 29, 2015 14:04
Show Gist options
  • Save steverobbins/731a394c448c1dd5917b to your computer and use it in GitHub Desktop.
Save steverobbins/731a394c448c1dd5917b to your computer and use it in GitHub Desktop.
Monitors a file's size and alerts you when it's stopped growing (useful if you need to wait for a long logging process to finish)
#!/bin/bash
if [ -z $1 ]
then
echo "Usage: watchsize <file>"
exit
fi
SIZELAST=0
SIZENOW=1
while [ $SIZENOW -gt $SIZELAST ]
do
sleep 1;
SIZELAST=$SIZENOW
SIZENOW=`du "$1" | cut -f1`
done
# ring da bell
echo -e '\a' || (echo -e '\a'; sleep 1; echo -e '\a')
echo "$1 has stopped growing at $SIZENOW bytes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment