Magento Keeps track of all logging information in its database. It logs everything that happens in the site i.e visitors information,customers logged in details,URLs visited etc. It has a log cleaning with Cron job setup by default to clear the old entries, but i found in magento forums that the default log cleaning is not working and also the database size increased because of these log entries. I went through the log module to see how the log cleaning and i found an important model class that does the job.
The Log module works based on the configuration in the admin, it keeps track of the log entries for the specified no of days in the admin. The Log entries older than the specified no of days will be deleted by this script.
Note: Please test this script in development environment and then move to production site.
Step 1: Navigation to System > Configuration > System > Log Cleaning in Magento Admin panel. Now decide for how many days you need to keep track of the log information. Say for example i want to keep track of the log entries for the last one month so I entered 30 days in Save Log, Days field.
Step 2: I Created a custom script that deletes the old log entries i.e Entries older than one month. The script contains no raw SQL queries it simply calls the model class which does the job. My Custom script is named as logclean.php and i dropped it in the Root folder
Requirement :- Magento