Scheduler task to delete old rows from database tables
Often customer databases are filled up with lots of syslog entries. Those entries are useful but in most cases having the logs for the X past weeks/months would be sufficient.
Provide a scheduler task to remove older entries regularly.
(issue imported from #M17970)
[FEATURE] Add table garbage collection scheduler task
This feature was implemented during T3BOARD11 bug auction. It is
kindly sponsored with 100 beers by jweiland.net and is called the
'Schnaps Hans scheduler task'
#1 Updated by Francois Suter over 7 years ago
Several tasks have been opened to clear various tables (cache, etc.). Why not trying to make it more general. I wrote an extension called "cachecleaner" which is designed to clean up arbitrary tables. It works as part of the CLI lowlevel cleaner for now, but could be adapted into a Scheduler task (I've been meaning to do that for a long time, actually).
#9 Updated by Christian Kuhn over 7 years ago
Patch set 4 is a revised version that handles more than just the sys_log table:
To prevent administrators from committing hazard to the database, tables that can be cleaned up must be registered in an own 'option' array (which extensions can add entries to). There a specific table and a time stamp field must be defined, the table will then be selectable in the task as additional field.
Per task only one table can be selected, there is no multi-select-option to simplify the logic a bit if configured tables 'vanish' from configuration if extensions are un-installed or configured otherwise (the according task will then throw an exception).
For the core tables: Currently only sys_log is configured as default table to be chosen. The following tables are candidates to be added to the configuration: sys_history, be_sessions, fe_sessions, fe_session_data. All of them already have some weird internal garbage collection implemented in the core, so that they are already garbage collected during fe/be calls sometimes. This could be cleaned up in an additional patch, which should add a registry handling to the garbage collection task that logs its last execution and only calls the currently built in core garbage collection if our new task did not run for a long time. Since there is no handling for this currently, I've not added those tables to the task, yet.