Check your logs if you are getting any time out or out of memory errors. I had this issue when I was adjusting how long to keep my logs in a large environment from never delete logs to keep the logs for a year. You can either increase the limits in your PHP settings or tell the settings to say keep logs for 1000 days let the clean task finish, set it to 365 days, let the clean up task finish, keep going down until you get to the desired time.
Hardware and performance
cannot purge standard log in Moodle 3.1 although set keep standard log only for 5 days
This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.