We are currently using a similar script (dedicated to sanitization) to the one you're looking for in our client's AtoM instances, in some production environments even.
We have set up CRON to run the script at 3am everyday (in some cases we schedule it to only run on Sundays).
The documentation is written in Brazilian Portuguese, but it is straightforward.
The script itself has some documentation that is printed to the terminal but you can delete or ignore all that.
Prof. Daniel Flores
/* ____________________________________ */