Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Webtools Releng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
webtools
Releng
Webtools Releng
Commits
cd76106c
Commit
cd76106c
authored
14 years ago
by
david_williams
Browse files
Options
Downloads
Patches
Plain Diff
cleanup more during daily cleanup
parent
f1742561
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
releng.control/cleanupArtifacts.sh
+103
-15
103 additions, 15 deletions
releng.control/cleanupArtifacts.sh
releng.control/removeIf.sh
+11
-15
11 additions, 15 deletions
releng.control/removeIf.sh
with
114 additions
and
30 deletions
releng.control/cleanupArtifacts.sh
+
103
−
15
View file @
cd76106c
...
...
@@ -10,30 +10,118 @@ then
source
${
RELENG_CONTROL
}
/commonComputedVariables.shsource
fi
# remove
artifact
s over n days old
# remove
directorie
s over n days old
# (where hours = 24 + (n * 24), basically, so that
# even n=0 means "1 day")
# set at 10 days, under assumption that before that time,
# artifacts will be "saved" elsewhere, if needed.
# if more cleanup is needed, we should take time, and
# existence of more recent builds into account, so we never
# delete the last existing build (even if "old").
# set at ndays, under assumption that before that time,
# direcotory will be "saved" elsewhere, if needed.
# We never delete the last existing build (even if "old").
ndays
=
4
;
artifactsDir
=
${
PROJECT_ARTIFACTS
}
;
# requires parent Directiory as first argument
# if nDays not specified as second argument, then 0 is assumed
# (which is one day)
# if "saveAtLeast" is not set, as third argument, then assumed to be 1
# (that is, at least "saveAtLeast" directories will be saved, no matter how old)
function
removeOldArtifactsDirectories
()
{
parentDir
=
$1
;
ndays
=
$2
;
saveAtLeast
=
$3
;
if
[
-z
$parentDir
]
then
echo
"ERROR: no parent directory specified in function call"
;
return
-1
;
fi
if
[
-z
ndays
]
then
echo
"INFO: ndays not specified, 1 day assumed"
;
ndays
=
0
else
echo
"INFO: ndays set to
$ndays
"
;
fi
if
[
-z
saveAtLeast
]
then
echo
"INFO: saveAtLeast not specified, 1 assumed"
;
saveAtLeast
=
0
else
echo
"INFO: saveAtLeast set to
$saveAtLeast
"
;
fi
echo
;
echo
" Removing
artifact
directories older than
${
ndays
}
days"
;
echo
" (from
${
ar
tifacts
Dir
}
)"
;
before
=
`
find
${
ar
tifacts
Dir
}
-mindepth
2
-maxdepth
2 |
wc
-l
`
;
echo
" Removing directories older than
${
ndays
}
days"
;
echo
" (from
under
${
p
ar
ent
Dir
}
)"
;
before
=
`
find
${
p
ar
ent
Dir
}
-mindepth
2
-maxdepth
2 |
wc
-l
`
;
echo
" number of directories before cleaning:
${
before
}
"
;
# empty directories often result from "bad builds". We remove those no matter how old
find
${
ar
tifacts
Dir
}
-mindepth
2
-maxdepth
3
-type
d
-empty
-exec
rm
-fr
'{}'
\;
find
${
p
ar
ent
Dir
}
-mindepth
2
-maxdepth
3
-type
d
-empty
-exec
rm
-fr
'{}'
\;
# now remove old ones
find
${
ar
tifacts
Dir
}
-mindepth
2
-maxdepth
2
-type
d
-ctime
+
$ndays
-execdir
${
RELENG_CONTROL
}
/removeIf.sh
'{}'
\;
find
${
p
ar
ent
Dir
}
-mindepth
2
-maxdepth
2
-type
d
-ctime
+
$ndays
-execdir
${
RELENG_CONTROL
}
/removeIf.sh
'{}'
$saveAtLeast
\;
after
=
`
find
${
ar
tifacts
Dir
}
-mindepth
2
-maxdepth
2 |
wc
-l
`
;
after
=
`
find
${
p
ar
ent
Dir
}
-mindepth
2
-maxdepth
2 |
wc
-l
`
;
echo
" number of directories after cleaning:
${
after
}
"
;
echo
echo
;
}
# requires parent Directiory as first argument
# if nDays not specified as second argument, then 0 is assumed
# (which is one day)
# if "saveAtLeast" is not set, as third argument, then assumed to be 1
# (that is, at least "saveAtLeast" directories will be saved, no matter how old)
function
removeOldArtifactsDirectories
()
{
parentDir
=
$1
;
ndays
=
$2
;
saveAtLeast
=
$3
;
if
[
-z
$parentDir
]
then
echo
"ERROR: no parent directory specified in function call"
;
return
-1
;
fi
if
[
-z
ndays
]
then
echo
"INFO: ndays not specified, 1 day assumed"
;
ndays
=
0
else
echo
"INFO: ndays set to
$ndays
"
;
fi
if
[
-z
saveAtLeast
]
then
echo
"INFO: saveAtLeast not specified, 1 assumed"
;
saveAtLeast
=
0
else
echo
"INFO: saveAtLeast set to
$saveAtLeast
"
;
fi
echo
;
echo
" Removing directories older than
${
ndays
}
days"
;
echo
" (from under
${
parentDir
}
)"
;
before
=
`
find
${
parentDir
}
-mindepth
1
-maxdepth
1 |
wc
-l
`
;
echo
" number of directories before cleaning:
${
before
}
"
;
# empty directories often result from "bad builds". We remove those no matter how old
find
${
parentDir
}
-mindepth
1
-maxdepth
1
-type
d
-empty
-exec
rm
-fr
'{}'
\;
# now remove old ones
find
${
parentDir
}
-mindepth
1
-maxdepth
1
-type
d
-ctime
+
$ndays
-execdir
${
RELENG_CONTROL
}
/removeIf.sh
'{}'
$saveAtLeast
\;
after
=
`
find
${
parentDir
}
-mindepth
1
-maxdepth
1 |
wc
-l
`
;
echo
" number of directories after cleaning:
${
after
}
"
;
echo
;
}
removeOldArtifactsDirectories
${
PROJECT_ARTIFACTS
}
3 1
;
removeOldDirectories
${
PROJECT_PROJECTS
}
1 0
;
removeOldDirectories
${
PROJECT_TESTS
}
1 0
;
This diff is collapsed.
Click to expand it.
releng.control/removeIf.sh
+
11
−
15
View file @
cd76106c
...
...
@@ -7,8 +7,14 @@ if [ -z $1 ]
echo
" This script requires an argument. "
;
exit
1
;
fi
foundDirectory
=
$1
nSave
=
$2
if
[
-z
$nSave
]
then
nSave
=
1
;
fi
# should already be in foundDirectory, if execDir used
cd
$foundDirectory
# move up one so we can examine syblings
...
...
@@ -20,7 +26,7 @@ ndirs=$(($ndirs - 1)); # don't count the "totals" line
# echo "NDirs: $ndirs"
# if only one left, do not remove it, no matter how old
if
[
$ndirs
-
eq
1
]
if
[
$ndirs
-
le
$nSave
]
then
exit
0
;
fi
...
...
@@ -35,18 +41,8 @@ fi
# adding a few "should never happen" errror checks
if
[
-d
$foundDirectory
]
then
basedirname
=
$(
basename
$foundDirectory
)
if
[[
"
$basedirname
"
=
~
[[
:digit:]]
{
14
}
]]
then
echo
"removing
$basedirname
"
rm
-fr
$foundDirectory
else
# patches is expected, warn of others
if
[
"patches"
!=
$foundDirectory
]
then
echo
"ERROR: The foundDirectory,
$foundDirectory
, didn't match timestamp pattern"
fi
fi
rm
-fr
$foundDirectory
echo
"removed
$foundDirectory
"
;
else
echo
"ERROR: the foundDirectory,
$foundDirectory
, is not a directory"
echo
"ERROR: the foundDirectory,
$foundDirectory
, is not a directory"
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment