X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=blobdiff_plain;ds=sidebyside;f=pull-mail;h=96532507a75b20abd32b04e482bee520131fc7f3;hb=25b6d00edebfca36db1f2f61ea073f5423f748d0;hp=a1959505a4f34f5000b544725d255c14330d8154;hpb=d4b1b0c18521d57183d981831661879bc6d60aee;p=bin.git diff --git a/pull-mail b/pull-mail index a195950..9653250 100755 --- a/pull-mail +++ b/pull-mail @@ -1,9 +1,24 @@ #! /bin/sh -if ! [ -e ~/.nomail ]; then - date >> ~/.fetchmail/log - fetchmail >> ~/.fetchmail/log - bsmtp-pull gluck +if [ -f ~/.nomail ] && [ "$1" != --force ]; then + exit 0 fi +loadavg="$(cut -d. -f1 /proc/loadavg)" +if [ "$loadavg" -ge 5 ]; then + # System load is too high. Don't contribute to it. + exit 0 +fi + +bsmtp-pull gluck + +hour="$(date +%H)" +case $hour in + 0[0-289]|[12]*) + date >> ~/.fetchmail/log + fetchmail >> ~/.fetchmail/log + logrotate -s ~/.fetchmail/logrotate.status ~/.fetchmail/logrotate.conf + ;; +esac + exit 0