From be22d976dd5f628e9313ab85ad8f7fe406d0a112 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 1 Jun 2022 15:00:39 +0200 Subject: [SSPS] Add dnbd3 stage4 cleanup cronjob --- .../dnbd3/etc/cron.daily/dnbd3-stage4-cleanup | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 satellit_installer/static_files/dnbd3/etc/cron.daily/dnbd3-stage4-cleanup 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 -- cgit v1.2.3-55-g7522