Hooks Cleanup Script
The Hooks cleanup script will loop through all configs provided (passed in as 'dbs') and check every centre's assets/hooks path. Any files or directories that are found here which exceed the "days" parameter will be removed.
The asset path checked is constructed from inc.Settings; $settings→_AssetsPath / centreDirName / assets / hooks
You can invoke the script as follows:
| php coredna_engine/coreDNA11/cron/cron_hooks_cleanup.php --db randys,cougar --days 35 | 
Arguments:
- --db: comma-separated list of configs to check, the code will change database and check every centre here
- --days: age limit for files & directories, if they exceed this number they will be removed.
The script will output in the terminal and (if configured) via Slack webhook
Example Output
| Hooks Cleanup ScriptThe following batches have been attempted to be removed on: 2021-04-15 14:17:38Databases: randys, cougarBatches Dirs checked ifthey are over 1 days oldTotal Batches Found: 141Batch DeleteSuccess: 141Batch DeleteError: 0(!) Errors:• This asset path does not exist: "/var/virtual/assets/randys/randysworldwidecom-stage/assets/hooks", skipping• This asset path does not exist: "/var/virtual/assets/randys/mediacenterrandysworldwidecom/assets/hooks", skipping• This asset path does not exist: "/var/virtual/assets/randys/mediacenterrandysworldwidecom-stage/assets/hooks", skipping• This asset path does not exist: "/var/virtual/assets/randys/usastandardgearcom/assets/hooks", skipping• This asset path does not exist: "/var/virtual/assets/randys/usastandardgearcom-stage/assets/hooks", skipping• This asset path does not exist: "/var/virtual/assets/randys/yukongearcom/assets/hooks", skippingResults:• (✓) Batch 'randys/randysworldwidecom/assets/hooks/06a01f24'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/11f27c14'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/26442fdf'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/274bb8cd'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/274caf45'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/298de4e1'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/2a4ab792'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/2aa43aeb'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/43b799c7'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/48a5bc79'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/4b3bc4c5'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/5104f47d'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/5a523999'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/7c8ad295'DeleteSuccessful• (✓) Batch 'randys/randysworldwidecom/assets/hooks/85124fd5'DeleteSuccessful... |