Hi people, I have implemented a quick and very effective workaround for the broken logrotation on all my Ubuntu boxes, I have the last 2 Ubuntu versions all upgraded to latest via apt-get. It also make sure the postgrey does not die on me. Perhaps this posting may help Postgrey users to solve the constant dying issues on Ubuntu.
22 06 * * * /bin/kill -9 `/usr/bin/pgrep postgrey-check.rc`
37 06 * * * echo "Daily logrotation." >/root/boot-reason
38 06 * * * /sbin/shutdown -r now
The idea is to "fix" the broken parts of the logrotation, therefore killing my own checking scripts before the logrotation at 23 06 and restarting the stuff after logrotation, yes in this case via re-boot witch helps a lot. I have an mail sent to me each time the server statrup with the reason given the content of an file called "/root/boot-reason". this way all my scripts etc can send me notes if they re-started the server and for what reason.
First the Postgrey Fix
in the file postgrey-check.rc i have
while read ans
#echo "Going to main loop"
if [ "$ans" = "" ]
problem=`echo $ans | grep 'Server configuration problem'`
if [ "$problem" != "" ] && grep "$problem" $LOGFILE > /dev/null
/usr/sbin/invoke-rc.d postgrey restart
/usr/sbin/invoke-rc.d postfix restart
echo 'Postgrey broken!' 2>&1 |/usr/bin/mailx -s "`uname -n` Postgrey And Postfix re-started" firstname.lastname@example.org
) < $LOGFILE
I loop through the logfile constantly grep for the error, then imediatly act! As this does not reboot the server I have to mail myself some message of this error occuring. The funny thing is since I actually re-boot the server just after each log-rotation Postgrey never have issues. Apearently Postgrey run into file access rights on Ubuntu after logrotation, I cannot confirm this but it does seem so. After re-booting Postgrey re-start properly.
Now the Startup
In the file /etc/rc.local
cat /root/boot-reason 2>&1 |/usr/bin/mailx -s "`uname -n` Server restarted" email@example.com
echo "No reason given" >/root/boot-reason
/usr/bin/postgrey-check.rc >/dev/null &
to get mailx use apt-get install mailx