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
13 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
15 die "no dbname" unless $dbname;
16 die "no dbuser" unless $dbuser;
18 my $dsn="dbi:Pg:dbname=$dbname";
19 $dsn .= ";host=$dbhost" if $dbhost;
20 $dsn .= ";port=$dbport" if $dbport;
22 my $db = DBI->connect($dsn,$dbuser,$dbpass);
24 die $DBI::errstr unless $db;
26 my $del_sth = $db->prepare(q[
27 DELETE FROM build_status
28 WHERE snapshot < (now() - interval '3 months')
30 my $del_recent_sth = $db->prepare(q[
31 DELETE FROM build_status_recent_500
32 WHERE snapshot < (now() - interval '3 months')
36 $del_recent_sth->execute();
38 my $buildlogs = "$ENV{BFConfDir}/buildlogs";
40 my @dirs = `find $buildlogs -mindepth 1 -type d -ctime +95`;
41 foreach my $dir (@dirs) {