thank you again.
yes, that would be an option, but I want the cleanup to happen based on a date/time set from inside WP, without the need for the user to fiddle with the server.
I figured I can make that work inserting my script at the top of advanced-cache.php file in the content folder.
In my case, I use WP to run a webshop and I want to clean the cache folder once after a scheduled sale starts and again after it ends, in order to display the correct pricing and banners throughout the site.