mysql is overkill for that.
Code:
filename=/tmp/foobar
count=2
oldcount=`cat $filename`
x=`dc << EOF
$count
$oldcount
+pq
EOF
`
echo $x > $filename
This is a simple sample. You'd want to have code to put a zero in the file after you run your hourly stats. And you'd want to replace the code to assign "count" with your numbers. And the filename becomes whatever you want to use to store the running total.
This adds the numbers as you go. You could keep all 12 by just using echo $count >> $filename ... and then you'd have the script part which creates the other average... but that is slightly different.
Code:
averagefuction() {
# do the averaging here and null the file out at the end.
> $filename
}
echo $count >> $filename
if [ `cat $filename | wc -l` -eq 12 ]; then
averagefunction
fi