5

I turned on Log Cleaning (under System -> Configuration -> System -> Log Cleaning). This is my configuration:

Log Cleaning Configuration

I set a Scheduled Task (I'm on Windows) to send a request to cron.php every 5 minutes. But nothing happens. I checked cron_schedule table and it didn't scheduled either. I also checked log_quote (and other log tables) and nothing cleaned.

What should I do to make it work?

13

Kick off the log cleaning yourself, manually (or set up in a CRON as I usually do):

Usage:  php -f log.php -- [options]
        php -f log.php -- clean --days 1

  clean             Clean Logs
  --days <days>     Save log, days. (Minimum 1 day, if defined - ignoring system value)
  status            Display statistics per log tables
  help              This help

So, to clean the log fully pass the flag option clean with a number of days to clean:

php -f shell/log.php clean --days 7
  • It's great but I'm not just cleaning Magento logs. I want to clean my custom module log messages so I was observing the log_log_clean_before event. – Pedram Behroozi Feb 18 '14 at 8:05
  • 1
    Well that's a horse of a different color. Post your module code, sonny-boy! Any log clean event should fire from running the cleaner above - so you likely have an issue elsewhere. – philwinkle Feb 18 '14 at 8:08
  • Yes, I explained the situation magento.stackexchange.com/a/15210/4276. It was just a misunderstanding of time :) – Pedram Behroozi Feb 18 '14 at 10:32
  • I am using Magento 1.9.2.4 and log.php is not cleaning the tables. I used clean --days 7 and is not cleaning anything. Tables status is the same after cleanings. I guess this is a bug in Magento. I truncated all tables mentioned in log.php file then I used this script again after one day. It is not working at all. – ADDISON74 Mar 18 '16 at 9:29
3

I managed to figure it out. The problem was difference of timezones between Magento and Database. Mysql was GMT but Magento was set at +3.5 (Asia/Tehran). So There was no problem actually. If you reach this problem set the Start Time based on Timezone you set in Magento before, but remember that that time in database may be saved differently. And it is confusing.

1

Usually I empty the cron_schedule table, flush the cache and run cron.php again. Magento schedules it's cron tasks in advance. How much exactly is configurable in system config > Advanced > System > Cron. It says: 'Generate Schedules Every' 1440 in my case and 'Schedule Ahead for' 1920. So either you'll have to wait for 1440 minutes before your changes take effect or you can empty your cron schedule table and flush cache to force rescheduling right away. I hope this works in your case.

  • Still doesn't work. I empty the table and the cache but log cleaning didn't schedule. – Pedram Behroozi Feb 17 '14 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.