Name

cleanmqlogs - Support Pac MS62 - manage MQSeries linear recovery logs

Synopsis

cleanmqlogs [ -z | -p | -u ] QueueManger...

Description

MQSeries linear recovery logs are great, but they also will also fill up the /var/mqm/log filesystem if you don't clean them up periodically. The script, cleanmqlogs, when run periodically by cron, at, or AutoSys, can do so for you.

** WARNING ** WARNING ** WARNING ** WARNING ** WARNING **

This script attempts to do a somewhat dangerous thing: remove files that a Queue Manager uses for recovery. If one were to delete a file that the Queue Manager still needs--the queue manager will not restart. This is bad. So use at your own risk.

Firstly, this document (and the supportpac instructions) assume that you know how to run a perl script in your environment (either for Windows or Unix). An appendix talks about this, in case you don't.

How does the script work? Periodically, the queue manager outputs messages to the Queue Manager's error log specifying the oldest logfile which must be maintained for restart and for media recovery. When the script is run, for each queue manager you specify, it parses the qmgr's error log and determines which files are older than what is required. Then, it either gzips, compresses, or unlinks (deletes), the files that are older that what MQ reports as necessary.

Now, if you never run rcdmqimg and you never restart your queue manager, you will never reduce the number of logs needed for media recovery. Therefore, this script will not gzip/compress/unlink anything. Not too useful.

Therefore, periodically (at least as periodically as you run this script), you should run rcdmqimg:

If you do that, the next time a message is written to the queue manager's error logs (which will not be immediately, BTW) the latest file needed for media recovery will be increased.

Note: as of MQ v5.2, you can use the -l option to rcdmqimg to immediately print a new message to the error logs.

Options

Note:The -n, -l, and -t options have been removed in favor of parsing the Windows Registry for this information.
-z
Gzip unnessesary log files. This is the default. If gzip is not in your path, you may need to either add its directory to your path, or edit the script's $gzip variable to specify its fully-qualified pathname. A copy of gzip for Windows can be found at http://www.shelden-associates.com/download/gzip.exe.
-u
Unlink (delete) unnessessary log files.
-p
Print the names of unnessessary log files. No cleanup will take place.
QueueManager
The name of the queue manager or managers whose recovery logs you want to clean up.

Automation

The script is usually run via cron on Unix, or via at on Windows. Depending on your traffic, you may need to run rcdmqimg and cleanmqlogs more frequently. But, if you wanted to run each daily at midnight and 1:00am:

Unix Cron

Add the following lines to mqm's crontab (omit the -l if you're using MQ v5.1 or earlier):

Windows Scheduler/at

Run the following two commands to have rcdmqimg and cleanmqlogs run by at (again, omit the -l if you're using MQ v5.1 or earlier):

Running a Perl script

Running cleanmqlogs is no different from running any other perl script. Here are basic instructions for Perl newbies. For more information, try http://www.perl.com.

Unix

To run the script (or any perl script) under Unix:
  1. find where your perl interpreter is located:
      which perl
    If it is not found, ask your system administrator where perl is located on your system, and if it isn't have the SA install it.
  2. Edit the first line of the script to specify the fully-qualified path to the perl interpreter. For example, if the which reported /usr/local/bin/perl, put:
      #! /usr/local/bin/perl
    in the first line of the script.
  3. If the download process generated dos-sytle newline characters in the script you'll need to remove them. One way to do so is with perl:
      perl -ne 's/\r//g; print' cleanmqlogs > cleanmqlogs.tmp
      mv cleanmqlogs.tmp cleanmqlogs
  4. Give the script execute permission:
      chmod +x ./cleanmqlogs
  5. And test to see if it will run correctly:
      ./cleanmqlogs -p QueueManagerName

Windows

Firstly, most Windows installations do not come with Perl installed. So, download it and install it. How to do so is beyond the scope of this document. Go to http://www.perl.com or http://www.activestate.com to obtain, download, and install perl.

Once you have done so:

  1. create an association between the .PL extension and the perl executable:
    • Go to Windows Explorer-> View-> Options-> File Types-> New Type...
    • Add the type Perl Script, with the mime type application/perl, and extension .PL.
    • Add an Open action, which should execute:
        c:\progra~1\perl\bin\Perl.exe "%1" %*
      assuming you installed perl in c:\Program Files
  2. Set the environment variable PATHEXT to be .PL;.COM;.EXE;.BAT;.CMD
  3. Rename the script cleanmqlogs.PL:
      move cleanmqlogs cleanmqlogs.PL
  4. Attempt to run the script:
      cleanmqlogs.PL -p QueueManagerName

    See Also

    Bugs

    Latest Version

    The latest version of this script can always be found at: http://www.shelden-associates.com/download/

    Author

    Brian T. Shelden <shelden@shelden-associates.com>

    Copyright

    Script and docs Copyright © 1999-2002,2006,2008 Shelden & Associates, Inc.