Skip to content

Instantly share code, notes, and snippets.

@Mic92
Created April 22, 2010 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mic92/375293 to your computer and use it in GitHub Desktop.
Save Mic92/375293 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$(pidof firefox)" ]
then
echo Please close all instance of firefox to unlock the database >&2
exit 1
else
echo Database optimization begin ...
echo -------------------------------
time for i in `find ~/.mozilla -name \*.sqlite`
do
before=`du $i -h | cut -f 1`
sqlite3 $i 'VACUUM;'
sqlite3 $i 'REINDEX;'
after=`du $i -h | cut -f 1`
file=$(basename $i)
[ $before != $after ] && echo $file: $before - $after || echo $file: $before
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment