How should a postLogFileHandler script look like?
WinCC OA triggers a Fileswitch when the parameter for maxLogFileSize is exeeded. In a 1st step the file extension of the affected log file will be renamed to „.bak“ and in a 2nd step a possible postLogFileHandler script will be executed for further activities. This file must be located in the \bin folder from the project and it should be named in dependencies of the used OS-System:
Windows OS : postLogFileHandler.cmd
Linux/Solaris OS : postLogFileHandler.sh
Possible example for this file on a Windows OS. This example will keep the 10 newest files of the same type (PVSS_II.log, WCCOActrl0.log, …) with a different file extension from 0 to 9. The oldest file will be deleted automatically if an 11th file is created.
This example script should be paste to a file with the name postLogFileHandler.cmd in the \bin folder from the project.
@echo off
IF EXIST %1.9 del %1.9
sleep 1
IF EXIST %1.8 move %1.8 %1.9
sleep 1
IF EXIST %1.7 move %1.7 %1.8
sleep 1
IF EXIST %1.6 move %1.6 %1.7
sleep 1
IF EXIST %1.5 move %1.5 %1.6
sleep 1
IF EXIST %1.4 move %1.4 %1.5
sleep 1
IF EXIST %1.3 move %1.3 %1.4
sleep 1
IF EXIST %1.2 move %1.2 %1.3
sleep 1
IF EXIST %1.1 move %1.1 %1.2
sleep 1
IF EXIST %1.0 move %1.0 %1.1
sleep 1
move %1 %1.0
The same file in a Linux environment could look similar but it is necessary to replace the OS specific command like move to mv or del to rm.