Hello,
The process is too “intensive” to start it randomly in background. Also, WP-Cron is not perfect (and can’t be since it is started when users explore your website) and will make a terrible experience for users who are unlucky to visit your website at the execution time. Plus it would be extremely difficult to develop, maintain, and more importantly debug. I thought about it many times but it wouldn’t end well 🙁
Hi Jordy,
Fully understood.
More specifically, what I am asking is: how can I call this process from my own external code, which already interacts with WordPress using the Codex API (I import WordPress into my own PHP script – which is launched via simple cron)?
We have a “maintenance window” even night when posts are synced with an external system, which seems like it would be a fine time to also do media cleanup.
Thanks!
Unfortunately impossible, because the client part (your computer) is gathering the information about the scanning and then calling the server for each file or bundle of files. It’s quite complex and there is a lot of programming involved if the server was capable of doing it, and I don’t think it will work properly at all neither… The clean up really should be done manually with a pair of eyes to look at it closely. It’s not a simple cache/drafts DB cleanup.