]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.weekly
Add logging to cronjobs
[dak.git] / config / debian / cron.weekly
1 #!/bin/sh
2 #
3 # Run once a week via cron, out of dak's crontab.
4
5 set -e
6 set -u
7 export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
8 . $SCRIPTVARS
9
10 # Start logging
11 NOW=`date "+%Y.%m.%d-%H:%M:%S"`
12 LOGFILE="$logdir/weekly_${NOW}.log"
13 exec > "$LOGFILE" 2>&1
14
15 cleanup() {
16   echo "Cleanup"
17   rm -f "$LOGFILE"
18 }
19 trap cleanup 0
20
21 ################################################################################
22
23 # Purge empty directories
24 echo "Purging empty directories in $ftpdir/pool/"
25
26 if [ ! -z "$(find $ftpdir/pool/ -type d -empty)" ]; then
27    find $ftpdir/pool/ -type d -empty | xargs rmdir;
28 fi
29
30 # Split queue/done
31 echo "Splitting queue/done"
32 dak split-done > /dev/null
33
34 # Vacuum the database
35 echo "VACUUM; VACUUM ANALYZE;" | psql --no-psqlrc projectb 2>&1 | grep -v "^NOTICE:  Skipping.*only table owner can VACUUM it$"
36
37 # Clean up apt-ftparchive's databases
38 cd $configdir
39 echo "Cleanup apt-ftparchive's database"
40 apt-ftparchive -q clean apt.conf
41 apt-ftparchive -q clean apt.conf.buildd
42
43 echo "Finally, all is done, compressing logfile"
44 exec > /dev/null 2>&1
45
46 bzip2 -9 "$LOGFILE"
47
48
49 ################################################################################