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
d0bdbd23
Commit
d0bdbd23
authored
14 years ago
by
david_williams
Browse files
Options
Downloads
Patches
Plain Diff
improve daily cleanup scripts
parent
6030ce00
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
releng.control/cleanupArtifacts.sh
+5
-80
5 additions, 80 deletions
releng.control/cleanupArtifacts.sh
with
5 additions
and
80 deletions
releng.control/cleanupArtifacts.sh
+
5
−
80
View file @
d0bdbd23
...
...
@@ -24,81 +24,6 @@ fi
# = = = = = = = = = = = = = = = = = = = = =
function
removeIf
()
{
# echo "arg: $1";
if
[
-z
$1
]
then
echo
" This script requires an argument. "
;
return
1
;
fi
foundDirectory
=
$1
# should already be in foundDirectory, if execDir used
cd
$foundDirectory
# adding a few "should never happen" errror checks
if
[
-d
$foundDirectory
]
then
rm
-fr
$foundDirectory
echo
" removed:
$foundDirectory
"
;
else
echo
"ERROR: the foundDirectory,
$foundDirectory
, is not a directory"
fi
}
function
removeArtifactsIf
()
{
# echo "arg: $1";
if
[
-z
$1
]
then
echo
" This script requires an argument. "
;
return
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
cd
..
currentDirectory
=
`
pwd
`
echo
" current working directory:
$currentDirectory
"
;
ndirs
=
`
ls
-lA
|
wc
-l
`
ndirs
=
$((
$ndirs
-
1
))
;
# don't count the "totals" line
# echo "NDirs: $ndirs"
# if only one left, do not remove it, no matter how old
# or, as improved ... if less than or equal to nSave is left, do not remove
if
[
$ndirs
-le
$nSave
]
then
exit
0
;
fi
# This is unexpected, since otherwise this method should not have been called.
# So, this check is just a safety check.
if
[
$ndirs
-lt
1
]
then
exit
101
;
fi
# ok, it is old, and not the only one left
# adding a few "should never happen" errror checks
if
[
-d
$foundDirectory
]
then
rm
-fr
$foundDirectory
echo
" removed:
$foundDirectory
"
;
else
echo
"ERROR: the foundDirectory,
$foundDirectory
, is not a directory"
fi
}
# requires parent Directiory as first argument
# if nDays not specified as second argument, then 0 is assumed
...
...
@@ -141,9 +66,9 @@ before=`find ${parentDir} -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
${
parentDir
}
-mindepth
2
-maxdepth
3
-type
d
-empty
-exec
rm
-fr
'{}'
\;
find
${
parentDir
}
-mindepth
2
-maxdepth
3
-type
d
-empty
-exec
dir
rm
-fr
'{}'
\;
# now remove old ones
find
${
parentDir
}
-mindepth
2
-maxdepth
2
-type
d
-atime
+
$ndays
-execdir
removeArtifactDirIf
'{}'
$saveAtLeast
\;
find
${
parentDir
}
-mindepth
2
-maxdepth
2
-type
d
-atime
+
$ndays
-execdir
${
RELENG_CONTROL
}
/
removeArtifactDirIf
.sh
'{}'
$saveAtLeast
\;
after
=
`
find
${
parentDir
}
-mindepth
2
-maxdepth
2 |
wc
-l
`
;
echo
" number of directories after cleaning:
${
after
}
"
;
...
...
@@ -183,9 +108,9 @@ 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
2
-type
d
-empty
-exec
rm
-fr
'{}'
\;
find
${
parentDir
}
-mindepth
1
-maxdepth
2
-type
d
-empty
-exec
dir
rm
-fr
'{}'
\;
# now remove old ones
find
${
parentDir
}
-mindepth
1
-maxdepth
1
-type
d
-atime
+
$ndays
-exec
removeIf
'{}'
\;
find
${
parentDir
}
-mindepth
1
-maxdepth
1
-type
d
-atime
+
$ndays
-exec
dir
${
RELENG_CONTROL
}
/
removeIf
.sh
'{}'
\;
after
=
`
find
${
parentDir
}
-mindepth
1
-maxdepth
1 |
wc
-l
`
;
echo
" number of directories after cleaning:
${
after
}
"
;
...
...
@@ -227,7 +152,7 @@ before=`find ${parentDir} | wc -l`;
echo
" number of directories and files before cleaning:
${
before
}
"
;
# remove all old directories and files
find
${
parentDir
}
-atime
+
$ndays
-exec
rm
-fr
'{}'
\;
find
${
parentDir
}
-atime
+
$ndays
-exec
dir
rm
-fr
'{}'
\;
after
=
`
find
${
parentDir
}
|
wc
-l
`
;
echo
" number of directories and files after cleaning:
${
after
}
"
;
...
...
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