From: Matthias A. <mat...@gm...> - 2017-02-12 15:25:56
|
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 |