+oldest=`date +%s`
+
+for fl in <% @streaming_clients %>; do
+ lastupdate=`wget -O - -q http://${fl}.openstreetmap.org/last_update.php`
+ if [[ "$?" != "0" ]]; then
+ oldest=0
+ break
+ else
+ epoch=`date +%s -d "$lastupdate"`
+ if [[ "$epoch" -lt "$oldest" ]]; then
+ oldest=$epoch
+ fi
+ fi
+done
+
+
+if [[ "$oldest" != "0" ]]; then
+ now=`date +%s`
+ timeago=$(( ( $now - $oldest ) / 60 + 180 ))
+ if [[ "$timeago" -le "180" ]]; then
+ echo "Oldest is in the future, something is wrong."
+ exit(1)
+ fi
+
+ echo "find -L <%= @archive_dir %> -mmin +$timeago -print0 | xargs -0r rm"
+fi
+
+diskfree=`df --output=pcent <%= @archive_dir %> | tail -n 1 | sed s:[^0-9.]::g