Data retention for Clickhouse persistent data storage

Please use this script only if you use per day partitions (default after version 2.0.87). If you installed FastNetMon before, please raise ticket to support team.

Clickhouse does not have bundled capability to remove old data but you can use CRON script to implement this task.

Please install Clickhouse library for Python:

Then, please create following script in /usr/local/bin/clickhouse_retention.py (please specify required number of days in value max_days):

Set executable bit for script:

Finally, please add following cron entry in file /etc/cron.d/clickhouse_data_cleanup:

This script will remove all data older than max_days at 2 AM.