Logrotate für Windows

Poor man’s logrotate for Windows von Nick Ivanov

Dieses kleine Scriptsystem stammt von www.datori.org und wurde an die Verwendung mit avanti unter Windows und zip statt gzip umgestellt.

 

logrotate_Windows_20190101.zip


Hier folgt ein Auszug aus der originalen  Beschreibung:
 

Poor man’s logrotate for Windows

...

The scipt, logrotatew.cmd, works like this: it reads a configuration file, where you specify the logs to be rotated and how many generations you want to keep. It then renames each specified log, for example, db2diag.log to db2diag.log.1, db2diag.log.1 to db2diag.log.2 etc. The oldest generation of the log is then deleted. Optionally, it can compress the rotated logs with any file compression utility with a command line interface, e.g. gzip, which has a Windows port. Check the sample configuration file for details.

 

Make sure you invoke the script with the following command line, otherwise it will not work properly:

 

cmd /v:on /c logrotatew.cmd [-f ]

 

argument is optional; if it is not specified the script will look for logrotatew.conf in the current directory.

 

There are some limitations, of course. Unlike the original logrotate, logrotatew does not:

 

  • save its state, therefore doing the entire rotation cycle every time it is invoked;
  • check the file size; if your log is empty it will still be rotated;
  • have an option of mailing the rotated log;

 

Also, as mentioned, it does rename the active log file. DB2 will happily recreate its log file if it doesn’t find it where it was before. However, some programs may not be that robust. If you choose to use my script, test in your environment before attempting to implement it on a production system.

 

You can download the script and a sample configuration file here (right-click and Save As…). As usual, caveat emptor, no warranties express or implied, use at your own risk, etc. etc.

 

Quelle: Nick Ivanov, datori.org

Artikel zuletzt bearbeitet am: 01.05.2019 14:50