blob: b606a66b750041d30a98755a52e0c5f211ef1ecd [file] [log] [blame]
david_williamse5298172007-12-20 03:30:54 +00001#!/bin/sh
2
3
4# remember to leave no slashes on filename in source command,
5# (the commonVariations.shsource file, that is)
6# so that users path is used to find it (first)
7if [ -n $BUILD_INITIALIZED ]
8then
9 source commonVariations.shsource
10 source ${BUILD_HOME}/releng.control/commonComputedVariables.shsource
11fi
12
13# remove artifacts over n days old
14# (where hours = 24 + (n * 24), basically, so that
15# even n=0 means "1 day")
16
david_williamse0f67a32007-12-20 03:39:17 +000017# set at 10 days, under assumption that before that time,
18# artifacts will be "saved" elsewhere, if needed.
david_williamsfd4706f2007-12-20 03:40:47 +000019# if more cleanup is needed, we should take time, and
20# existence of more recent builds into account, so we never
21# delete the last existing build (even if "old").
david_williamseececc12007-12-20 04:36:02 +000022
david_williamse0f67a32007-12-20 03:39:17 +000023n=10;
david_williamseececc12007-12-20 04:36:02 +000024artifactsDir=${BUILD_HOME}/artifacts;
david_williamse5298172007-12-20 03:30:54 +000025
david_williamseececc12007-12-20 04:36:02 +000026echo;
27echo " Removing artifact directories older than ${n} days";
28echo " (from ${artifactsDir})
29before=`find ${artifactsDir} -mindepth 2 -maxdepth 2 | wc -l`;
30echo " number of directories before cleaning: ${before}";
david_williamse5298172007-12-20 03:30:54 +000031
david_williamseececc12007-12-20 04:36:02 +000032find ${artifactsDir} -mindepth 2 -maxdepth 2 -ctime +$n -exec rm -fr '{}' \;
david_williamse5298172007-12-20 03:30:54 +000033
david_williamseececc12007-12-20 04:36:02 +000034after=`find ${artifactsDir} -mindepth 2 -maxdepth 2 | wc -l`;
35echo " number of directories after cleaning: ${after}";
36echo;