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.
In crontab
Code:
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
Note: 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
Code:
#!/bin/bash
LOGFILE=/var/log/syslog
(
while read ans
do
DUMMY=
done
#echo "Going to main loop"
while :
do
read ans
if [ "$ans" = "" ]
then
sleep 1
else
problem=`echo $ans | grep 'Server configuration problem'`
if [ "$problem" != "" ] && grep "$problem" $LOGFILE > /dev/null
then
/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" root@domain.tld
fi
fi
done
) < $LOGFILE
Note: 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
Code:
cat /root/boot-reason 2>&1 |/usr/bin/mailx -s "`uname -n` Server restarted" root@domain.tld
echo "No reason given" >/root/boot-reason
/usr/bin/postgrey-check.rc >/dev/null &
to get mailx use apt-get install mailx
Recent comments
1 day 10 hours ago
1 day 19 hours ago
1 day 21 hours ago
1 day 23 hours ago
2 days 35 min ago
2 days 2 hours ago
2 days 3 hours ago
2 days 4 hours ago
2 days 20 hours ago
2 days 21 hours ago