0

Ok so I have a patch that looks like below, it does a good job of deleting 2 day and older logs but however it just leaves the folder itself. I tried adding the section above which is bolded but it does not work. Any idea how to get rid of the dynamically generated folder. They have names like (log/RD0003FFA1230E and logs/RD0003FFA12729), but my script does delete all the logs inside those just not these folders.

   <scheduling>
     <agent type="Sitecore.Tasks.CleanupAgent">
       <files hint="raw:AddCommand">
         **<remove folder="$(dataFolder)/logs" pattern="*.*" maxAge="2.00:00:00"/>**
         <remove folder="$(dataFolder)/logs">
           <patch:attribute name="pattern">*log.*.tx*</patch:attribute>
           <patch:attribute name="maxAge">2.00:00:00</patch:attribute>
           <patch:attribute name="recursive">true</patch:attribute>
         </remove>
1
  • If you make the pattern just the wildcard it should delete folders too. Commented Aug 9, 2022 at 23:33

1 Answer 1

2

Here are two attributes you need to take care of for Sitecore.Tasks.CleanupAgent to delete the log files and folders -

  • pattern = Use regex for deleting the files since you want to delete the folder then you need to pass the * as a wildcard. <patch:attribute name="pattern">*log.*.tx*</patch:attribute> will just delete files with matching pattern and pattern="*.*" will delete all the files but not folders.
  • recursive = Use this attribute to delete files and folders on a deep level(recursively), generally we don't need to set this attribute if we are using the * wildcard value in the pattern but we had some issues in PaaS long time back where it work after set it's value to true.

try below configration to fix this issue -

 <remove folder="$(dataFolder)/logs">
       <patch:attribute name="pattern">*</patch:attribute>
       <patch:attribute name="maxAge">2.00:00:00</patch:attribute>
       <patch:attribute name="recursive">true</patch:attribute>
     </remove>
2
  • Great thanks for the direction! I just added it in and we shall see what we get. Commented Aug 10, 2022 at 22:08
  • 1
    Just marked it as answered, had to wait for a deployment and we are set. Thanks again. Commented Aug 31, 2022 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.