How to patch Sitecore Cleanup Agent?

It’s good to have all Sitecore environment well maitained and cleaned.

With this setting log files will be split by Size parameter

On one of the solutions (see picture above), I found that the log file is splitted by size. It caused that extension is not txt but a number.

Generally, it’s not an issue, but if you look on default Sitecore Cleanup Agent configuration, by default, only *.txt files are removed not *.txt.[NUMBER].

Default Sitecore Cleanup Agent configuration

But you can quickly patch Cleanup Agent settings and configure your cleaning task as you need. Below you can find an example:

<?xml version="1.0" encoding="utf-8" ?>

Purpose: This is an example how to modify CleanupAgent base on environment rule.
<configuration xmlns:patch="" xmlns:role=""
               xmlns:env="" xmlns:set="" >
      <agent type="Sitecore.Tasks.CleanupAgent" method="Run" interval="06:00:00" patch:instead="*[@type='Sitecore.Tasks.CleanupAgent']" env:require="!PROD">
      <!-- Specifies files to be cleaned up.
              If rolling="true", [minCount] and [maxCount] will be ignored.
              [minAge] and [maxAge] must be specified as [days.]hh:mm:ss. The default value
              of [minAge] is 30 minutes.
              [strategy]: number of files within hour, day, week, month, year
              [recursive=true|false]: descend folders?
      <files hint="raw:AddCommand">
        <remove folder="$(dataFolder)/logs" pattern="*log.*.txt*" maxAge="10.00:00:00" recursive="true" />
        <remove folder="$(dataFolder)/diagnostics" pattern="*.*" maxAge="10.00:00:00" recursive="true" />
        <remove folder="$(dataFolder)/viewstate" pattern="*.txt" maxAge="2.00:00:00" recursive="true" />
        <remove folder="$(tempFolder)/diagnostics" pattern="*.*" maxAge="00:10:00" recursive="true" />
        <remove folder="/App_Data/MediaCache" pattern="*.*" maxAge="90.00:00:00" recursive="true" />

This and more patch examples you can find in repository:

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: