Changing Database Cleanup script options and commands

BMC Server Automation provides a default Network Shell script and Network Shell Script Job that you can use to check and clean various elements of the BMC Server Automation infrastructure, using BLCLI cleanup commands. You can edit and adjust this Database Cleanup script according to your cleanup needs.

Note

For the script to function properly, the role that runs the script must be granted the BL_Administration.System_Cleanup authorization.

To examine or change the options and commands included in the default script:

  1. In the Depot folder, navigate to the BMC Maintenance Depot object and select the BSA Recommended Database Cleanup Script.
  2. Right-click the script and select Open.

The following topics describe the options, parameters, and commands that you can use with the Network Shell script.

Script options

The Script Options panel provides identifying information for the Network Shell script. The default settings are shown in the following figure.

The Script Type setting must be set to Execute the script separately against each host.

The script executes repeatedly from the Application Server, each time running on a different server. This option uses the Network Shell runscript program, which can run the same script on multiple machines. The script uses environment variables local to the Application Server.

Script parameters

The Parameters panel lets you define parameters that are replaced with server property values when the script runs. Using this panel, you can add flags to parameters, you can specify whether the flag is required at runtime, and, if necessary, require a value to be provided for the flag. In addition, you can define a default value for a flag, make the default value editable when the script is run, and require a value to be entered for the flag at runtime.

When you deploy a Network Shell script, BMC Server Automation automatically generates a master script that controls the script's deployment and execution. The system uses the parameters defined here to generate values in the master script.
The following figure shows the parameters for the script. The following table describes the parameters.

Note

You cannot change the order of the script parameters.

Description of parameters

Note

Script parameters are not case-sensitive.

Parameter name Description
ExecutionMode Sets the Execution mode for the script. There are two options: Typical mode and individual command mode.

With the Typical mode, the script executes a series of recommended delete commands. The script executes the following commands in the order listed below:

  • Delete cleanupHistoricalData (all object types, sequentially)
  • Delete executeRetentionPolicy
  • Delete cleanupDatabase
  • Delete hardDeleteAllSharedObjects
  • Delete cleanupFileServer
You can also choose to execute an individual delete command. Enter one of the values shown in #Supported execution modes to execute an individual delete command. This option is useful if you want to cleanup a specific type of data, such as agent logs.
ContinueOnError Specifies if the script is to keep processing if it runs into errors. By default, the NSH Script uses Continue on error = true. If set to true, upon encountering an error the script will log the error and then continue with the cleanup run.
MaxDuration Specifies the overall maximum run-time for the script. By default, the NSH Script uses an overall maximum run-time of 720 minutes. You can change the overall maximum duration default value.
DurationDistribution

Distributes the run-time across the delete commands in below shares (percent).

  • JobRunEvent = 8% (60 minutes)
  • AuditTrail = 8% (60 minutes)
  • cleanupDatabase = 50% (360 minutes)
  • hardDeleteAllSharedObjects = 17% (120 minutes)
  • cleanupFileServer = 17% (120 minutes)

These are the recommended settings for the script. BMC recommends that you do not change these settings. However, if you are very familiar with the landscape of the objects in the database that you want to delete, then you might want to adjust the settings. To adjust the settings, enter the settings in quotes, as shown below:
“JobRunEvent=8 AuditTrail=8 cleanupDatabase=50 hardDeleteAllSharedObjects=17 cleanupFileServer=17”

RetentionTime

Specifies the number of days that must be exceeded for the script to delete the specified data. This parameter is used by the following execution modes:

TYPICAL

HISTORY_RDR

CLEAN_AGENT

CLEAN_ALL_AS

CLEAN_AS

CLEAN_REPEATER

It is used by the following BLCLI commands:

Delete cleanupHistoricalData

Delete cleanupAgent

Delete cleanupAllAppServerCaches

Delete cleanupAppServerCache

Delete cleanupRepeater

The default value is 14 days.

ObjectType

Deletes a specific type of object. To use this parameter, you must be using an execution mode of HISTORY_O. Use one of the following values:

AuditResult

AuditTrail

ComplianceResult

JobRunEvent

JobSchedule

SnapshotResult

RoleName Deletes objects from the database that were created by a specific role.
TargetDevices Lists the device names which have an Application Server cache or a repeater. The execution modes CLEAN_AS and CLEAN_REPEATER use this parameter.
TargetSize Specifies the maximum size, in MB, for the repeater staging directory.

Supported execution modes

The following table lists the BLCLI commands and the mode values that are supported for use with the database and file server cleanup script.

Mode value Command executed What it does
HISTORY Delete cleanupHistoricalData Cleans up BMC Server Automation historical data based on retention time. Historical data includes Compliance Job results, Audit Job results, snapshot results, job run events, job schedules, and the audit trail.
HISTORY_O Cleans up BMC Server Automation historical data for the specified OBJECT_TYPE (a required argument) using the default retention of 14 days.
HISTORY_RDR Cleans up BMC Server Automation objects older than the RetentionTime parameter value for RoleName. The RoleName parameter can be literally null to cleanup data from all roles.
RETENTION Delete executeRetentionPolicy Marks entries for deletion based on retention time in the BMC Server Automation database. It marks old job runs and automatically created jobs and depot objects.
CLEAN_DB Delete cleanupDatabase

Deletes database rows for objects that have been previously marked for deletion.

Note: Certain objects are not deleted due to potential object dependencies. The cleanup process deletes all top-level model objects of the classes listed in the hk_allowed_classes database table, as well as all their child classes (which are not listed in this table). BMC recommends that you do NOT modify the contents of the hk_allowed_classes table.

CLEAN_DB_TL Performs a BMC Server Automation Database cleanup with the duration limitation specified in the DurationDistribution parameter.
CLEAN_OBJECTS Delete hardDeleteAllSharedObjects Deletes database rows for shared data objects with the duration limitation specified in DurationDistribution parameter. It includes data for shared files, checksum files, ACL entries, and internal values generated by BMC Server Automation.
CLEAN_FS Delete cleanupFileServer Cleans all the unused files from the file server and from temporary file storage on the Application Server.

Note: When a Custom Package Deploy Job runs, it creates a subdirectory under the BLPackage directory for every iteration. Even after the job run history is removed by the retention policy, these directories still exist. These directories are not removed by the cleanup script.
CLEAN_FS_TL Performs a FileServer cleanup with the duration limitation specified in the DurationDistribution parameter.
CHECK_FS Delete checkFileServerIntegrity Performs a FileServer integrity check.
FULL_CLEANUP Delete performFullCleanupJob Deletes all objects marked for deletion and cleans all unused files from the file server and the temporary file storage area on the Application Server.
CLEAN_AGENT Delete cleanupAgent

Cleans up old temporary files on a target server (agent) that are older than the RetentionTime parameter value. This includes old files that were created by Deploy Jobs (transactions, staging, and so on).

Note: To clean up transactions, the value of the server's TRANSACTIONS_DIR property is used to locate the transactions directory. For information about configuring this property, see Configuring the location of the transactions directory.

CLEAN_ALL_AS Delete cleanupAllAppServerCaches Deletes old temporary files on all the Application Servers that are currently up and running (and accessible). It removes files older than the RetentionTime parameter value.
CLEAN_AS Delete cleanupAppServerCache Deletes old temporary files on a specific Application Server (any files older than the RetentionTime parameter value).
CLEAN_REPEATER Delete cleanupRepeater Cleans up files from the staging directory of a repeater server. This cleanup removes files that have not been accessed for the RetentionTime parameter value.
Was this page helpful? Yes No Submitting... Thank you

Comments