Tag Archives: site

Rotate Logs for Apache on Linux using logrotate

Using Apache’s access_log and error_log files are useful. Not only a system administrator should use it, but also a developer should grow habit of using these log files for debugging purpose. But sometimes for high traffic web site/applications these files can grow HUGE and real fast.

In real life, you probably need log file up to a certain point. If anything goes wrong and you know about it immediately you will probably need the current log file plus few from past to compare. In case if you find out about an issue with the site/application a week later – then you should really think about how to fix that problem.

Anyhow, this article is to show you how you can tune pre-configured logrotate on linux system for apache (HTTPD) to meet your needs. Every path I’m going to refer here are based on CentOS 5.6 OS.

Usually the logrotate configuration file is located under /etc/logrotate.conf. But logroate also has individual configuration for different linux processed. One of them is Apache. By default the configuration looks like this:

/var/log/httpd/*log {
missingok
 notifempty
 sharedscripts
 postrotate
 /sbin/service httpd reload > /dev/null 2>/dev/null || true
 endscript
}

To understand what each of the items mean please refer to http://tinyurl.com/ansqol

For my purpose I just added two lines to have this:

/var/log/httpd/*log {
size=1024M
rotate 5
missingok
notifempty
sharedscripts
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}

size=1024M – The logs should be rotated when it is 1G in size.

rotate 5 – The logs are rotated 5 times before it is removed.

Thanks!

How to delete a locked file in Windows?

Sometimes when you try to delete a file on Windows it says file cannot be delete as it is used by another program; you must close the program to delete the file. Well, almost all the time you actually know which program to close in order to delete the file (also rename the file). But today when I tried to delete a file (which was not open in any program nor did I use this file for over three months) Windows was showing the message. You cannot really say which program or process is using it. So I downloaded Process Explorer from Microsoft’s site which you can use to see which process or program is using the file you are trying to delete.

After you run the Process Explorer go to “Find” menu and click on “Find Handle or DLL …” (Ctrl+F). Type in the file name (full or partial) you are having trouble deleting or renaming and hit Search. Process Explorer will list all the processes or programs using this file. When I searched for the file I was having problem with it showed that the “Explorer” is using it! So what can I do in that case?

From “Task Manager” if I kill the “Explorer” process I cannot browse to the folder so using “Task Manager” I ran “Command Prompt” and from command line I changed directory to the desired location. Typed the command to delete the file “del filename.ext”. I was able to delete the file and then using “Task Manager” I started “Explorer” again. It was easy but “Process Manager” made it easy to find the process. So many hidden stuff that we have on Windows!

Image Menu using Moo Tools

It is called Image Menu and uses Moo Tools. I found this example on AjaxRain.com which is a vault for Ajax, Javascript and DHTML examples. The demo is located at PhatFusion.net and it also lists the features, usages and options.

After I downloaded the Javascript and CSS I changed the menu of my own site. With the new funky looking menu, I’ve decided to change the whole theme of the site and now it looks like this. I am not sure how long this will last, as I’ve tried many funky stuff before but eventually I turn back to my old and simple looking site. Try it yourself and have fun.