aboutsummaryrefslogtreecommitdiffstats
path: root/service/cleaner.sh
blob: bd67705188552bf3816fc2c0146d4ba2f1d38bdb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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
	if [ -z "$files" ]; then
		filecount=0
	else
		filecount=$(echo "$files" | wc -l)
	fi
	echo "[ $(date +%T) ] Removed $filecount old files!"
fi

touch "$timeref"