From 1a9caf08ee030c7e7ef948e8da3eda02378131f0 Mon Sep 17 00:00:00 2001 From: Dmitry Ozerov Date: Tue, 2 Jun 2020 14:34:07 +0200 Subject: [PATCH] cleanup script for the buffer --- scripts/delete_old_files_in_buffer.sh | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 scripts/delete_old_files_in_buffer.sh diff --git a/scripts/delete_old_files_in_buffer.sh b/scripts/delete_old_files_in_buffer.sh new file mode 100755 index 0000000..1d0db5a --- /dev/null +++ b/scripts/delete_old_files_in_buffer.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +hours=5 +threshold=80 + +if [ $# = 1 ] +then + threshold=$1 +fi +if [ $# = 2 ] +then + hours=$2 +fi + +df -h | grep BUFFER > /dev/null +if [ $? != 0 ] +then + # BUFFER is not present + exit +fi + +occupancy=`df -h /gpfs/photonics/swissfel/buffer | grep BUFFER | awk '{print $5}' | sed 's/%//'` +if [ ${occupancy} -lt ${threshold} ] +then +# echo OK, not action + exit +fi + +#find /gpfs/photonics/swissfel/buffer/JF* -type f -mmin +$((${hours}*60)) -delete +find /gpfs/photonics/swissfel/buffer/JF*/M* -type d -mmin +$((${hours}*60)) -delete