#!/bin/bash

if [ -f $HOME/.bash_profile ]; then
  . $HOME/.bash_profile
fi

factor=10
mindelay=60

cd $EMGDIR

starttime=`date +"%s"`
perl $HOME/bin/hourly_summary.pl >> /tmp/hourly_summary.log 2>&1
endtime=`date +"%s"`
elapsed=`expr $endtime - $starttime`
delay=`expr $elapsed \* $factor`
if [ $delay -lt $mindelay ]; then
  delay=$mindelay
fi
sleep $delay

starttime=`date +"%s"`
perl $HOME/bin/hourly_summary_connector.pl >> /tmp/hourly_summary_connector.log 2>&1
endtime=`date +"%s"`
elapsed=`expr $endtime - $starttime`
delay=`expr $elapsed \* $factor`
if [ $delay -lt $mindelay ]; then
  delay=$mindelay
fi
sleep $delay

exit 0

