Vacuum Firefox, Thunderbird and Eclipse Squlite script

Wrote this little bash script after I learned about squlite vacuum.

#!/bin/bash

#Best to stop the apps before but just incase
if [ $(pgrep thunderbird >> /dev/null 2>&1)$? = "0" ]; then
echo "please stop thunderbird"
sleep 10
pkill thunderbird
fi

if [ $(pgrep firefox >> /dev/null 2>&1)$? = "0" ]; then
echo "please stop firefox"
sleep 10
pkill firefox
fi

if [ $(pgrep eclipse >> /dev/null 2>&1)$? = "0" ]; then
echo "please stop eclipse"
sleep 10
pkill eclipse
fi

for X in $(locate *.sqlite |grep $(id -un)); do ls -Al $X; done |awk 'BEGIN {print "Start Size"}{sum += $5}END {print "Total File Size: " sum/1024/1024" MB"}'

echo "starting sqlite VACUUM"
for X in $(locate *.sqlite |grep $(id -un)); do sqlite3 $X VACUUM; done

for X in $(locate *.sqlite |grep $(id -un)); do ls -Al $X; done |awk 'BEGIN {print "End Size"}{sum += $5}END {print "Total File Size: " sum/1024/1024" MB"}'

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*