Fork me on GitHub

Delete a Group of Messages from the Postfix Queue

This article will show you how to delete a group of messages out of a postfix mail queue, from the command line, using a number of standard Linux commands. It is not intended to be a tutorial on Postfix, GAWK, grep, regular expressions, or any other Linux command, but many of them will be covered in a little bit of detail and, at the end, you will be able to add this to your bag of tricks.

Keep Apache Running

I recently encountered a problem on one of my servers with logrotate and the Apache web server. Logrotate is configured to run daily and help me keep all the log files at a manageable size. In the configuration, I have it set to rotate my Apache2 log files on a weekly basis.

The problem was, on one server, apache was not properly restarting after the log files were rotated. The script would run on Sunday morning, my logs would show that apache shutdown gracefully, but it would never come back up. The only log entry that gave me any indication of an issue was simply:
[notice] caught SIGWINCH, shutting down gracefully

In doing some research, I found that there were others with a similar issue, but no one had a solution. The best I could do was come up with a work-around. I created the following script and added it to my /etc/cron.hourly folder:
if [ `pgrep apache2 -c` -le "0" ]; then /etc/init.d/apache2 start; fi

Now, every hour, this little script will count the number of apache processes that are running and, if it doesn't find any, start apache. 

Seems easy enough to me and, hopefully, this will help someone else out there, too.