From: Chris <cpo...@em...> - 2017-02-12 17:04:04
|
On Sun, 2017-02-12 at 16:25 +0100, Matthias Andree wrote: > Am 12.02.2017 um 15:56 schrieb Chris: > > > > postrotate > > /usr/local/bin/fetchmail --quit > > /usr/local/bin/fetchmail -v --nokeep --nosyslog --logfile > > /home/chris/fetchmaillog --uidl -m procmail > > endscript > > [...] > > running postrotate script > > fetchmail: background fetchmail at 3786 killed. > > fetchmail: can't accept options while a background fetchmail is > > running. > > > > > I don't understand why it worked the first time but not the 2nd as > > nothing was changed in between. > > Hi Chris, > > Looks like a race between the three instances of fetchmail involved: > > 1. you have 3786 > 2. postrotate starts fetchmail -q, which just signals 3786 to exit, > but > does not wait for its exit (because it's not its child that wouldn't > be > 100% safe anyhow) > 3. postrotate immediately starts a new fetchmail, which stumbles over > the still existing instance that's still cleaning up. > > It'd probably be good to wait until the prior instance has really > quit > before starting the next one, like so (adjust the pid file's path): > > /usr/local/bin/fetchmail --quit > > while [ -e /path/to/fetchmail.pid ] ; do sleep 1 ; done > > /usr/local/bin/fetchmail -v --nokeep --nosyslog --logfile > /home/chris/fetchmaillog --uidl -m procmail > > > and possibly adding a counter so it does not wait too long or > otherwise > use SIGKILL to get rid of the old instance. > > Neither will be 100% bullet-proof unless you defer to a service > supervisor such as runit, upstart, systemd, or thereabouts, and just > request a fetchmail restart from such a supervisor in your postrotate > script. > > HTH > Matthias > Thanks Matthias, I'm sure it will. I'll make the changes and give it some test runs until I get it right. Appreciate the assistance. Chris -- Chris KeyID 0xE372A7DA98E6705C 31.11972; -97.90167 (Elev. 1092 ft) 11:01:44 up 9 days, 2:59, 2 users, load average: 0.22, 0.16, 0.10 Ubuntu 16.04.1 LTS, kernel 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 |