On production server, one folder was taking too much space. On further investigation , it was found that on downloading any pdf file from the site, it was keeping a copy of file in downloads folder under website root directory. With time , it started consuming lots of space.
If we just want to keep record of last few days data, we can leverage Sitecore inbuilt CleanUpAgent task. We just need to provide the path of the folder where files are getting accumulated and set the duration like after how many days again it should do clean up.
Add below code in patch file to delete files older than 30 days.

<scheduling>
<agent type=”Sitecore.Tasks.CleanupAgent” method=”Run”>
<files hint=”raw:AddCommand”>
<remove folder=”C:\inetpub\wwwroot\localSitecoreInstance\Website\App_Data\abc/Downloads” pattern=”.” maxAge=”30.00:00:00″ recursive=”true” />
</files>
</agent>
<scheduling>

Importance of following attributes
folder – path of folder where clean up agent should look up for files.
pattern – dot(.) will indicate any type of file should be considered.
maxAge – will delete files older than maxAge value . Its format is – [days.]hh:mm:ss
recursive – descend folders if true.

Happy Learning 🙂




Leave a Comment

Your email address will not be published. Required fields are marked *