aboutsummaryrefslogtreecommitdiffstats
path: root/service/container/cleaner.sh
blob: 2882608b307bd93b0aa34885f69b8017d327471d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

timeref="/data/lastclean"

if [ -z "$RESULTDIR" ]; then
	echo "RESULTDIR is undefined! skipping cleanup.."
	exit 1
fi

if [ -f "$timeref" ]; then
	files="$(find "$RESULTDIR" -mindepth 1 \! -newer "$timeref")"
	echo "$files" | while read path; do
		rm -rf "$path"
	done
	echo "[ $(date +%T) ] Removed $(echo -n "$files" | wc -l) old files!"
fi

touch "$timeref"