View Single Post
Old 9th November 2011, 14:41
Mark_NL Mark_NL is offline
Senior Member
Join Date: Sep 2008
Location: The Netherlands
Posts: 912
Thanks: 12
Thanked 100 Times in 96 Posts

When you connect, you run fetchmail and kill, but you want only to kill if the queue is empty .. this will only be checked once .. if the queue at that point is not empty, the connection will stay open indefinitly, not what you want i think.

maybe you should fork another script after fetchmail. That script will keep checking the mailqueue and when it's empty, close ppp0


/usr/bin/fetchmail -v -f /etc/fetchmailrc -L /var/log/fetchmail.log
/script/location/ &
while ( true )
 SIZE=`find /var/spool/postfix/{deferred,active,maildrop}/ -type f | wc -l`;
 if [ $SIZE -eq 0 ];
  killall wvdial;
 sleep 10;

exit 0; will check every 10 seconds if there are still mails in the queue left to be send, if none, execute killall, else wait 10seconds and check again.

I used find, since it's much faster then mailq when you have a lot of mail in the queue.
Real men don't backup... Real men cry!
Reply With Quote