diff options
-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 |