-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from brown-bnc/feat-clean-by-usage
scale days to clean by usage percentage
- Loading branch information
Showing
2 changed files
with
19 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
|
||
ARG UBUNTU_VERSION=22.04 | ||
FROM ubuntu:$UBUNTU_VERSION | ||
ENV PARENT_PATH=/data/xnat | ||
ENV DAYS_TO_CLEAN=60 | ||
ENV DAYS_TO_CLEAN=100 | ||
|
||
COPY cleanup_cache.sh /cleanup_cache.sh | ||
RUN chmod +x /cleanup_cache.sh | ||
|
||
# Clean logs files older than $DAYS_TO_CLEAN days | ||
CMD /usr/bin/find $PARENT_PATH/home/logs -type f -name '*.log.*' -mtime +$DAYS_TO_CLEAN -delete\ | ||
&& /usr/bin/find $PARENT_PATH/cache -type f -mtime +$DAYS_TO_CLEAN -delete\ | ||
&& /usr/bin/find $PARENT_PATH/build -type f -mtime +$DAYS_TO_CLEAN -delete | ||
CMD /usr/bin/find $PARENT_PATH/home/logs -mindepth 1 -type f -name '*.log.*' -mtime +$DAYS_TO_CLEAN -delete && \ | ||
/usr/bin/find $PARENT_PATH/prearchive -mindepth 1 -type f -mtime +$DAYS_TO_CLEAN -delete && \ | ||
/usr/bin/find $PARENT_PATH/archive -mindepth 1 -type f -mtime +$DAYS_TO_CLEAN -delete && \ | ||
/usr/bin/find $PARENT_PATH/build -mindepth 1 -type f -mtime +$DAYS_TO_CLEAN -delete && \ | ||
/usr/bin/find $PARENT_PATH/inbox -mindepth 1 -type f -mtime +$DAYS_TO_CLEAN -delete && \ | ||
/cleanup_cache.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
usage=$(df --output=pcent $PARENT_PATH/cache/ | awk 'NR==2 {gsub("%",""); print $1}') # Get the usage of the cache folder | ||
|
||
if [ $usage -gt 75 ]; then | ||
DAYS_TO_CLEAN=$((DAYS_TO_CLEAN / usage)) | ||
fi | ||
|
||
/usr/bin/find $PARENT_PATH/cache -mindepth 1 -type f -mtime +$DAYS_TO_CLEAN -delete |