1 #!/bin/bash
   2 
   3 cache=$0.cache
   4 time1=$(date +%s)
   5 time2=$(date +%s -r $cache)
   6 diff=$(($time1 - ${time2:-0}))
   7 
   8 (( $diff > ${1:-300} )) && fetchmail.sh -c |
   9 awk '{ n += $1 } END { print n }' > $cache
  10 
  11 n=$(< $cache)
  12 [[ $n != 0 ]] && echo  $n
[raw]