IBM Support

How to Delete Old Log and Model Upload Files in Planning Analytics

How To


Summary

This technote describes how to automate the deletion of old log and model upload files.

Objective

Log files

If Planning Analytics cannot update and create log files (for example, there is no longer any free space on the drive on which the log files are stored), Planning Analytics shuts down gracefully.

It is good practice to delete old log files. A retention period should be agreed upon by all stakeholders, for example 100 days, and any log files older that that age can be deleted.

Model upload files

TurboIntegrator datasource files are uploaded to the model_upload folder, which is located in the model's Data folder.

Text data files are often large resulting in the Data folder becoming bloated with historic text files that were used once, and are no longer required. It can even contain files that were uploaded in error. Unless the model_upload folder is excluded, Data folder backups include these text files; these files mean that the backup takes longer to perform, and the backups take up more disk space.

The Planning Analytics model is often migrated by copying the Data folder from Production to Development and UAT environments. Text files that are used in one environment, might not be relevant in another environment; or can even pose a security risk (for example, confidential data files are accidentally transferred from Production to Development).

It is good practice to delete old model upload files. Generally the retention requirement for model upload files is less than that for log files.

Steps

A TurboIntegrator process can be created that deletes old files. This process can be scheduled to run regularly by being placed in a chore.

Log files

Ensure that the LoggingDirectory parameter exists in the TM1s.cfg configuration file, and that its value is different from the DataBaseDirectory parameter.

The Get-ChildItem Powershell command can be used to identify and delete old files. The following sample code can be placed in the Prolog of a TI process. The GetProcessErrorFileDirectory command obtains the location of the log file folder. A cut-off date of 100 days is being used as an example; all files more than 100 days old will be deleted from the log file folder.

#Region Constants

# Do not wait for the command to finish executing, to minimise risk of hanging and locking
nWait = 0;

#EndRegion



#Region Delete log files more the 100 days old

sFolder = GetProcessErrorFileDirectory;
nDays = 100;

# Powershell command to be executed
sCommand = 'Powershell Get-ChildItem -Recurse -Path ';
sCommand = sCommand | '''' | sFolder | '''';
sCommand = sCommand | ' -File | Where{ $_.LastWriteTime -lt (get-date).AddDays( 0 - ';
sCommand = sCommand | NumberToString( nDays );
sCommand = sCommand | ' ) } | Remove-Item -Force';

# Run the PowerShell command
ExecuteCommand( sCommand, nWait );

#EndRegion
Model upload files

Similar code can be added to the TI process for the model upload files. However, the administrator might not want to delete files that are used to define the datasource layout for TI processes. If a naming convention is chosen for these files, then they can be excluded from the automatic deletion. In the following example, these files are named with a Template_ prefix. A cut-off date of 7 days is being used.

#Region Delete model_upload files more the 7 days old

sFolder = '.\model_upload\';
nDays = 7;

# Do not delete files whose names start with the "Template_" prefix
sFileKeep = 'Template_*';

# Powershell command to be executed
sCommand = 'Powershell Get-ChildItem -Recurse -Path ';
sCommand = sCommand | '''' | sFolder | '''';
sCommand = sCommand | ' -Exclude ';
sCommand = sCommand | '''' | sFileKeep | '''';
sCommand = sCommand | ' -File | Where{ $_.LastWriteTime -lt (get-date).AddDays( 0 - ';
sCommand = sCommand | NumberToString( nDays );
sCommand = sCommand | ' ) } | Remove-Item -Force';

# Run the PowerShell command
ExecuteCommand( sCommand, nWait );

#EndRegion

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSD29G","label":"IBM Planning Analytics"},"ARM Category":[{"code":"a8m50000000KzL5AAK","label":"Planning Analytics-\u003EPlanning Analytics Workspace-\u003EAdministration"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Product Synonym

PA;PAW;TM1

Document Information

Modified date:
28 June 2022

UID

ibm16598321