diff options
author | Simon Rettberg | 2022-06-01 15:00:39 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-06-01 15:00:39 +0200 |
commit | be22d976dd5f628e9313ab85ad8f7fe406d0a112 (patch) | |
tree | 5826e85b82d6e35c507c86e4537969ebd31d624b | |
parent | [SSPS] Add simple weekly config backup (diff) | |
download | setup-scripts-be22d976dd5f628e9313ab85ad8f7fe406d0a112.tar.gz setup-scripts-be22d976dd5f628e9313ab85ad8f7fe406d0a112.tar.xz setup-scripts-be22d976dd5f628e9313ab85ad8f7fe406d0a112.zip |
[SSPS] Add dnbd3 stage4 cleanup cronjob
-rwxr-xr-x | satellit_installer/static_files/dnbd3/etc/cron.daily/dnbd3-stage4-cleanup | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/satellit_installer/static_files/dnbd3/etc/cron.daily/dnbd3-stage4-cleanup b/satellit_installer/static_files/dnbd3/etc/cron.daily/dnbd3-stage4-cleanup new file mode 100755 index 0000000..7a43f0a --- /dev/null +++ b/satellit_installer/static_files/dnbd3/etc/cron.daily/dnbd3-stage4-cleanup @@ -0,0 +1,17 @@ +#!/bin/bash + +# Find all .meta files in stage 4 directory +mapfile -d '' list < <( find /srv/openslx/nfs/stage4/bwlp/ -type f -name "*.meta" -print0 ) + +now="$( date +%s )" +for file in "${list[@]}"; do + # get the atime value from it; this is the last time a client asked for the according image + atime="$( grep -oP '(?<=^atime=).*$' "$file" )" + diff="$(( (now - atime) / 86400 ))" + # check if atime is more than 60 days ago, or continue with next image + (( diff > 60 )) || continue + # Older than 60 days, fire away + file="${file%.meta}" + rm -f -- "$file" "$file".* # No space between $file and .* !! +done +exit 0 |