-
Notifications
You must be signed in to change notification settings - Fork 1
/
05vacuum
50 lines (39 loc) · 989 Bytes
/
05vacuum
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/system/bin/sh
#Defrags database files
# Output the script name for easier run-parts debugging
echo Now running $0
LOG_FILE=/data/logs/vacuum-databases.log
# do nothing if less than 7 days
find $LOG_FILE -type f -mtime +7 -delete
# Check to see if the sqlite3 binary exists
SQL=`which sqlite3`
echo $SQL
if [ x = "x$SQL" ] ; then
echo "sqlite3 binary not found, exiting"
exit 1
fi
if ! test -f $LOG_FILE; then
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "Starting Sqlite Vacuum $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for i in \
`find /data -iname "*.db"`
do \
$SQL $i 'VACUUM;';
echo Vacuum $i | tee -a $LOG_FILE;
done;
for i in \
`find /dbdata -iname "*.db"`
do \
$SQL $i 'VACUUM;';
echo Vacuum $i | tee -a $LOG_FILE;
done;
for i in \
`find /sdcard -iname "*.db"`
do \
$SQL $i 'VACUUM;';
echo Vacuum $i | tee -a $LOG_FILE;
done
echo "Sqlite Vacuum finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
fi