Maintain Logfiles
What is it?
maintain_logfiles.pl deletes XP2 Connector log files that are older than a configured number of days. The script is run on a schedule to prevent log files from accumulating indefinitely on the AIX platform.
- Use this script as a recurring OpCon job to automate log maintenance
- Add it to the
SMAUtilityschedule to run it consistently alongside other maintenance tasks
Log file naming
Log files are separated by job run. Each log file name is made up of four parts:
- The XP2 Connector script that ran
- The XP2 application that was run
- The start time of the job, formatted as
YYYYMMDDHHMMSS - The PID number for the process
The log file for ccstmt1 that started at 09:32:36 on 02/27/2020 with a PID of 13762792:
run_xp_job-ccstmtl-20200227093236-13762792.log
Command line
To maintain the logs generated by the XP2 Connector, create an OpCon job with the following command line:
/ops/bin/maintain_logfiles.pl
It is recommended that this job be added to the SMAUtility schedule.
Command line parameters
Specify the location of the log files and the number of days to retain directly in the script.
LOGDIR
This is the path to where the logs are located in the installation directory.
DAYS2KEEP
This is the number of days of logs to retain.
The following shows the parameters as they appear in the maintain_logfiles.pl file:
#!/bin/sh
export LOGDIR=/ops/bin/log
export DAYS2KEEP=3
echo "The following files appear to be too old and will be deleted"
echo "------------------------------------------------------------"
find $LOGDIR -type f -name \*.log -mtime \
+$DAYS2KEEP -exec echo {} \; find $LOGDIR -type f -name \*.log -mtime \
+$DAYS2KEEP -exec rm -f {} \; echo "Finished"