Clear MVS log files

Tip to the hat at Johan and Rene (from the Discord channel).

MVS keeps logs of important events, which is convenient when trouble shooting. When we do not perform housekeeping, these logs fill up and cause MVS to spit out all kinds of annoying messages. There’s two types of log files.

ERP (Error Recovery Program)

The first one is SYS1.LOGREC and it contains records about errors and failures at the hardware level, or for selected software errors or system conditions. They are created by the Error Recovery Program (ERP). The records can be formatted for viewing by the EREP program (Environmental Record Editing and Printing Program). A job to clear SYS1.LOGREC is stored in SYS2.PROCLIB(CLEARERP).

SMF (System Management Facility)

The other one is SYS1.MANX or SYS1.MANY, and contains records created by SMF (System Management Facility) about all the activities on the system. Another job in SYS2.PROCLIB, CLEARSMF, can be used from the console to clean a SYS1.MANX(Y) data set. That job does not use EREP. The records in SYS1.MANX(Y) are different from those in SYS1.LOGREC.

Cleaning the logs from a job

We can clear the log files by submitting through a job that we submit or with commands from the console. I put together a job that will clear all of the logs above:

//GAWRMLOG JOB CLASS=A,MSGLEVEL=(1,1),MSGCLASS=A,NOTIFY=HERC01  
//*                                                             
//* CLEAR AND INITIALIZE HARDWRAE VENT RECORDER DATASET         
//*                                                             
//EREP     EXEC PGM=IFCDIP00                                    
//SERERDS  DD  DSN=SYS1.LOGREC,DISP=OLD,                        
//             VOL=SER=MVSRES,                                  
//             UNIT=3350                                        
//*                                                             
//* CLEAR AND INITIALIZE SMF LOG X                              
//*                                                             
//SMFDMPX EXEC PGM=IFASMFDP                                     
//DUMPIN   DD  DISP=SHR,DSN=SYS1.MANX                           
//DUMPOUT  DD  DUMMY                                            
//SYSPRINT DD  SYSOUT=*                                         
//*                                                             
//* CLEAR AND INITIALIZE SMF LOG Y                              
//*                                                             
//SMFDMPY EXEC PGM=IFASMFDP                                     
//DUMPIN   DD  DISP=SHR,DSN=SYS1.MANY                           
//DUMPOUT  DD  DUMMY                                            
//SYSPRINT DD  SYSOUT=*                                         
//                                                                                                                   

Submit this job and check the output for MAX CC = 0. NOTE: one of the SMF steps will probably end with CC 16, as it tries to clear the active log file.

Cleaning the logs from the console

ERP

You can clear your SYS1.LOGREC data sets from the console, using. the command:

/s clearerp

The output should look similar to this:

HHC00008I /s clearerp                                           
21.30.31 STC  835  $HASP100 CLEARERP ON STCINRDR                
21.30.31 STC  835  $HASP373 CLEARERP STARTED                    
21.30.31 STC  835  IEF403I CLEARERP - STARTED - TIME=21.30.31   
21.30.31 STC  835  IFC001I  D=3350 N=0B F=000D0000 L=000E0007 S=000D000002 DIP COMPLETE
21.30.31 STC  835  IEF404I CLEARERP - ENDED - TIME=21.30.31                            
21.30.31 STC  835  $HASP395 CLEARERP ENDED                                             
21.30.31 STC  835  $HASP150 CLEARERP ON PRINTER2        17 LINES                       
21.30.31           $HASP160 PRINTER2 INACTIVE - CLASS=Z                                
21.30.31 STC  835  $HASP250 CLEARERP IS PURGED 

SMF

You can clear your SYS1.MANX (MANY) data sets from the console, using. the commands:

/s clearsmf,man=x   (or man=y)

Check the output; it might be something like:

HHC00008I /s clearsmf,man=x
11.04.51 STC  833  $HASP100 CLEARSMF ON STCINRDR
11.04.51 STC  833  $HASP373 CLEARSMF STARTED
11.04.51 STC  833  IEF403I CLEARSMF - STARTED - TIME=11.04.51
11.04.51 STC  833 *00 IFA006A REQUEST MADE TO DUMP ACTIVE SMF DATA SET - REPLY CANCEL
11.04.53 STC  815  IEE600I REPLY TO 00 IS;'CANCEL'
11.04.53 STC  833  IFA007I SMF DUMP CANCELLED
11.04.53 STC  833  IEF404I CLEARSMF - ENDED - TIME=11.04.53
11.04.53 STC  833  $HASP395 CLEARSMF ENDED 
11.04.54 STC  833  $HASP150 CLEARSMF ON PRINTER2        28 LINES
11.04.54           $HASP160 PRINTER2 INACTIVE - CLASS=Z
11.04.54 STC  833  $HASP250 CLEARSMF IS PURGED

In case you get the message IFA006A about trying to dump the active SMF dataset, try to switch the datasets first:

/switch smf

That should produce:

HHC00008I /switch smf                     
14.13.20          *IEE362A SMF ENTER DUMP FOR SYS1.MANY ON MVSRES
14.13.20           IEE360I SMF NOW RECORDING ON SYS1.MANX ON MVSRES TIME=14.13.20
14.13.20 STC  840  $HASP100 SMFDAILY ON STCINRDR
14.13.20 STC  840  $HASP373 SMFDAILY STARTED
14.13.20 STC  840  IEF403I SMFDAILY - STARTED - TIME=14.13.20    
14.13.20 STC  840  IEF404I SMFDAILY - ENDED - TIME=14.13.20                      
14.13.20 STC  840  $HASP395 SMFDAILY ENDED      
14.13.20 STC  840  $HASP150 SMFDAILY ON PRINTER2        36 LINES
14.13.20           $HASP160 PRINTER2 INACTIVE - CLASS=Z      
14.13.20 STC  840  $HASP250 SMFDAILY IS PURGED 

Now try the clear command again:

/s clearsmf,man=x

This time all should go well and give us::

HHC00008I /s clearsmf,man=x                                                          
14.21.02 STC  843  $HASP100 CLEARSMF ON STCINRDR                                     
14.21.02 STC  843  $HASP373 CLEARSMF STARTED                                         
14.21.02 STC  843  IEF403I CLEARSMF - STARTED - TIME=14.21.02                        
14.21.02 STC  843  IEF404I CLEARSMF - ENDED - TIME=14.21.02                          
14.21.02 STC  843  $HASP395 CLEARSMF ENDED                                           
14.21.02 STC  843  $HASP150 CLEARSMF ON PRINTER2        24 LINES                     
14.21.02           $HASP160 PRINTER2 INACTIVE - CLASS=Z                              
14.21.02 STC  843  $HASP250 CLEARSMF IS PURGED

Now you might want to switch the datasets again:

/switch smf

That’s all folks!