Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have this script inside /etc/ppp/ip-up.d/script

#!/bin/sh
/usr/sbin/postqueue -c /etc/postfix -f
/usr/bin/fetchmail -v -f /etc/fetchmailrc -L /var/log/fetchmail.log
while ! postqueue -p | grep -q empty; do
  sleep 1
done
killall wvdial

in this script it disconects my modem when detects that the mail queue is empty, also i wish to check if the fetchmail process is still running or execute the part of the while just and just after the fetchmail command finish to do his job completely.

some help please?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Since you are not running fetchmail in daemon mode, the script will not start the while loop until fetchmail has exited.

I don't think you will save any time by starting your while loop before fetchmail finishes running.

share|improve this answer
    
Yes thats the point y was thinking at, until fetchmail exit of work it will do the while check, but in the practice i dont know why but it is procesing the while check and if the queue gets empty it disconects my modem letting to fecthmail at the half way, thats why i would like to add a command to start the while loop before fetchmail or add that besides to check if the queue is empty check if the process of fecthmail is not running –  nerdhacker Nov 10 '11 at 21:04
    
Can you please post a sanitized version of your fetchmailrc? –  Jeff Strunk Nov 10 '11 at 21:10
    
defaults proto pop3 poll pop.gmail.com user "userxxx" pass "password" is userxxxx ssl –  nerdhacker Nov 10 '11 at 21:36
    
I think something else must be ending your connection early. Put some debug echo statements in your script to tell you when things are happening. –  Jeff Strunk Nov 10 '11 at 21:46
    
Hmm great idea, please how can i put this? i am not too experiencied in bash scripting –  nerdhacker Nov 10 '11 at 21:49
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.