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="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/"
               xmlns:env="http://www.sitecore.net/xmlconfig/env/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" >
  <sitecore>
    <scheduling>
      <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" />
      </files>
    </agent>
	</scheduling>
  </sitecore>
</configuration>

This and more patch examples you can find in repository:

https://github.com/RobsonAutomator/patch-sitecore

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Google photo

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

Twitter picture

You are commenting using your Twitter 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: