#!/bin/sh

logfile=logs/pubcloud-logfile.txt

perl bin/pubcloud-watcher.pl > $logfile 2>&1

# keep failed logs, and the last successful run to avoid filling the disk.
if ! grep SUCCESS $logfile >/dev/null ; then
	echo "Note: This scripts occasionaly fails with out of memory ..."
	echo "bin/pubcloud-watcher failed:"
	cat $logfile
	mv $logfile $logfile.`date +"%Y-%m-%d:%H-%M-%S"`
else
	#rm $logfile
	# mv $logfile $logfile.`date +"%Y-%m-%d:%H-%M-%S"`
	
	touch $logfile
fi
