From fe98d2b1b7cb10e80ece9a280e0af9116e3ffae8 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 23 Oct 2017 15:47:11 +0200 Subject: bin/cleanup: remove successful-logs separately and only after 14 days --- bin/cleanup | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'bin/cleanup') diff --git a/bin/cleanup b/bin/cleanup index 2350702..60e4ca6 100755 --- a/bin/cleanup +++ b/bin/cleanup @@ -56,31 +56,29 @@ fi rm -f "${build_log_directory}/error/${s}."* done -# only keep 10 newest logs per package +# only keep 10 newest logs per failed package -for sub_dir in 'error' 'success'; do - - find "${build_log_directory}/${sub_dir}" -maxdepth 1 -type f -printf '%f\n' | \ - sed 's|^\(.*\)\(\.\([^.]\+\)\.build-log\.gz\)$|\1\2 \3 \1|' | \ - sort -k3,3 -k2r,2 | \ - uniq -f2 --group=prepend | \ - cut -d' ' -f1 | \ - ( - count=0 - while read -r a; do - if [ -z "${a}" ]; then - count=0 - continue - fi - if [ ${count} -ge 10 ]; then - echo "${build_log_directory}/${sub_dir}/${a}" - fi - count=$((count+1)) - done - ) | \ - xargs -rn1 rm +find "${build_log_directory}/error" -maxdepth 1 -type f -printf '%f\n' | \ + sed 's|^\(.*\)\(\.\([^.]\+\)\.build-log\.gz\)$|\1\2 \3 \1|' | \ + sort -k3,3 -k2r,2 | \ + uniq -f2 --group=prepend | \ + cut -d' ' -f1 | \ + ( + count=0 + while read -r a; do + if [ -z "${a}" ]; then + count=0 + continue + fi + if [ ${count} -ge 10 ]; then + rm "${build_log_directory}/error/${a}" + fi + count=$((count+1)) + done + ) -done +# only keep namcap logs of last 2 weeks for succeeded packages +find "${build_log_directory}/success" -maxdepth 1 -type f -mtime +14 -delete # remove old package meta data delete_old_metadata -- cgit v1.2.3-70-g09d2