3 # Called by the user the web server runs as to clean up old database
4 # records and old build logs
11 use vars qw($dbhost $dbname $dbuser $dbpass $dbport
14 use FindBin qw($RealBin);
15 require "$RealBin/../BuildFarmWeb.pl";
17 die "no dbname" unless $dbname;
18 die "no dbuser" unless $dbuser;
20 my $dsn="dbi:Pg:dbname=$dbname";
21 $dsn .= ";host=$dbhost" if $dbhost;
22 $dsn .= ";port=$dbport" if $dbport;
24 my $db = DBI->connect($dsn,$dbuser,$dbpass);
26 die $DBI::errstr unless $db;
28 my $del_sth = $db->prepare(q[
29 DELETE FROM build_status
30 WHERE snapshot < (now() - interval '3 months')
32 my $del_recent_sth = $db->prepare(q[
33 DELETE FROM build_status_recent_500
34 WHERE snapshot < (now() - interval '3 months')
38 $del_recent_sth->execute();
40 my $buildlogs = "$RealBin/../buildlogs";
42 my @dirs = `find $buildlogs -mindepth 1 -type d -ctime +95`;
43 foreach my $dir (@dirs) {