Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment Client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Imldeployment Client
Commits
be7f4c0e
Commit
be7f4c0e
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add deletion of logs
parent
9e590abf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
deploy_app.sh
+26
-0
26 additions, 0 deletions
deploy_app.sh
with
26 additions
and
0 deletions
deploy_app.sh
+
26
−
0
View file @
be7f4c0e
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
# 2021-05-27 v0.4 <axel.hahn@iml.unibe.ch> FIX first install
# 2021-05-27 v0.4 <axel.hahn@iml.unibe.ch> FIX first install
# 2021-07-08 v0.5 <axel.hahn@iml.unibe.ch> added function "runas"
# 2021-07-08 v0.5 <axel.hahn@iml.unibe.ch> added function "runas"
# 2021-11-01 v0.6 <axel.hahn@iml.unibe.ch> save config diffs
# 2021-11-01 v0.6 <axel.hahn@iml.unibe.ch> save config diffs
# 2021-11-02 v0.7 <axel.hahn@iml.unibe.ch> delete logs keping N files
# ======================================================================
# ======================================================================
...
@@ -22,6 +23,9 @@ selfdir=$( /bin/pwd )
...
@@ -22,6 +23,9 @@ selfdir=$( /bin/pwd )
tmpdir
=
/var/tmp/imldeployment_packages
tmpdir
=
/var/tmp/imldeployment_packages
logdir
=
/var/log/imldeployment-client
logdir
=
/var/log/imldeployment-client
# keep last N logs per project
typeset
-i
iKeep
=
10
wait
=
0
wait
=
0
# wait=1
# wait=1
...
@@ -253,6 +257,27 @@ function deploy(){
...
@@ -253,6 +257,27 @@ function deploy(){
cd
$(
dirname
$0
)
cd
$(
dirname
$0
)
}
}
# delete old logfiles keeping the last N files
# param string name of project
function
logdelete
(){
local
sProfile
=
$1
# order files by time
typeset
-i
local
_iFiles
=
$(
ls
-1t
${
logdir
}
/
${
sProfile
}
__.
*
|
wc
-l
)
header
"DELETE LOGS
${
logdir
}
/
${
sProfile
}
__* ... keep
$iKeep
"
if
[
$_iFiles
-gt
$iKeep
]
;
then
ls
-1t
${
logdir
}
/
${
sProfile
}
__.
*
|
sed
-n
"
${
iKeep
}
,
${
_iFiles
}
p"
|
while
read
mylogfile
do
echo
-n
"deleting "
ls
-l
"
${
mylogfile
}
"
&&
rm
-f
"
${
mylogfile
}
"
done
else
echo
SKIP: deletion ... less than
$iKeep
files found
fi
}
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# MAIN
# MAIN
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
...
@@ -322,6 +347,7 @@ fi
...
@@ -322,6 +347,7 @@ fi
for
myprofile
in
$allprofiles
for
myprofile
in
$allprofiles
do
do
deploy
$myprofile
|
tee
${
logdir
}
/
${
myprofile
}
__
$(
date
+%Y-%m-%d__%H%I%S
)
.log
deploy
$myprofile
|
tee
${
logdir
}
/
${
myprofile
}
__
$(
date
+%Y-%m-%d__%H%I%S
)
.log
logdelete
$myprofile
profile
=
profile
=
done
done
...
...
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