c=1

stopfile=/data/seestats/stop_lt
runfile=/data/seestats/run_st

while [ 1 ]
do

	if [ -f "$runfile" ]
	then
		echo "$runfile found."
		echo "Waiting for session to end ..."
		sleep 60

	else 	
		echo "---------------"
		echo "Long term $c times" $(date +%s) $(date)  	


		# 1 hour
		# More delay may lead to loss of valuable data 
		# (e.g not sure whether all dmesg logs will be captured)
		# <Needs testing> 
		sleep 3600 

		/data/seestats/scripts_set3.sh


		if [ -f "$stopfile" ]
		then
			echo "$stopfile found."
		break
		fi

		(( c++ ))
	fi
done
