This document contains an example IBM i CL program that will
perform the following steps:
- Disable
compact_filter notes.ini parameter to prevent its interference with the
compact to be ran.
2. End
the Domino server
a. If
Domino server cannot be ended in 12 minutes an error will be posted and
maintenance tasks will be aborted.
- Rename
the current log.nsf and domlog.nsf file.
- Submit
a job to run fixup –j on an
indirect file named adminfiles.ind
- Submit
a job to run compact –c on an indirect file named adminfiles.ind
- Submit
a job to run updall –r on an
indirect file named adminfiles.ind
- Submit
a job to start the Domino server
In order to use the script you will need the following
items:
- An
indirect file. For information on
using and creating indirect files refer to the Domino wiki article “Using
indirect files to run maintenance tasks”.
- A job
queue to be used by your maintenance jobs. For example: CRTJOBQ JOBQ(MYLIB/DOMMAINT)
TEXT('Job queue to be used for Domino Maintenance')
- A
subsystem job queue entry configured to only allow one job to run at a
time. This is to prevent multiple
maintenance tasks from running on the same database at the same time. Here is an example of adding the job
queue entry to the QBATCH subsystem:
ADDJOBQE SBSD(QBATCH)
JOBQ(MYLIB/DOMMAINT) MAXACT(1) SEQNBR(60)
To run the script, call the program passing the server name and subsystem name. For
example:
CALL MYLIB/Program_Name PARM(‘Server_Name’ ‘Subsystem_Name’)
Example Script:
PGM PARM(&SERVERNAME &SUBSYSTEM)
DCL VAR(&SERVERNAME) TYPE(*CHAR)
DCL VAR(&SUBSYSTEM) TYPE(*CHAR) LEN(10)
DCL VAR(&DATETIME) TYPE(*CHAR) LEN(17)
DCL VAR(&DATE) TYPE(*CHAR) LEN(8)
DCL VAR(&NEWOBJ) TYPE(*CHAR) LEN(18)
DCL VAR(&NEWOBJ2) TYPE(*CHAR) LEN(21)
DCL VAR(&COUNT) TYPE(*DEC) LEN(2 0)
DCL VAR(&ERRCOD) TYPE(*CHAR) LEN(4) VALUE(X'00000000')
DCL VAR(&CHARCOUNT) TYPE(*CHAR) LEN(2)
CHGVAR VAR(&COUNT) VALUE(1)
/* Disable Compact_Filter to allow compact to run on desired databases. A configuration document is recommended way to automatically enable this setting if it is desired. */
SBMDOMCMD CMD('set config compact_filter=') SERVER(&SERVERNAME)
MONMSG MSGID(CPF0000)
DLYJOB DLY(5)
/* End the Domino Server and Subsystem */
ENDDOMSVR SERVER(&SERVERNAME)
MONMSG MSGID(LNT0000 CPF0000)
ENDSBS SBS(&SUBSYSTEM)
MONMSG MSGID(CPF0000)
/* Attempt to allocate Domino Server subsystem Description in order to verify Domino server ended successfully */
ALCOBJ OBJ((QUSRNOTES/&SUBSYSTEM *SBSD *EXCL)) WAIT(660)
/* Verify server is ended Note that wait time should be higher than the server shutdown timeout defined in the server document */
MONMSG MSGID(CPF1002) EXEC(DO)
ENDDOMSVR SERVER(&SERVERNAME) OPTION(*IMMED)
MONMSG MSGID(LNT0000 CPF0000)
/*Try again for subsystem */
ALCOBJ OBJ((QUSRNOTES/&SUBSYSTEM *SBSD *EXCL)) WAIT(60)
MONMSG MSGID(CPF1202) EXEC(DO)
SNDPGMMSG MSG('Unable to End Domino server - Domino maintenance tasks cancelled')
GOTO CMDLBL(END)
ENDDO /* END OF SECOND MONMSG(CPF1202 */
ENDDO /*END OF FIRST MONMSG(CPF1202) */
MONMSG MSGID(CPF0000)
/* Rename log.nsf and domlog.nsf */
SETDOMENV SERVER(&SERVERNAME) /* Set current path to data directory */
CALL PGM(QWCCVTDT) PARM('*CURRENT' ' ' '*YYMD' &DATETIME &ERRCOD) /* Get current systemdate and time in YYYYMMDD */
CHGVAR VAR(&DATE) VALUE(%SST(&DATETIME 1 8)) /* Get just the date portion */
CHGVAR VAR(&NEWOBJ) VALUE('log' *CAT &DATE *CAT '.NSF')
CHGVAR VAR(&NEWOBJ2) VALUE('domlog' *CAT &DATE *CAT '.NSF')
RENAMELOG:
RNM OBJ(log.nsf) NEWOBJ(&NEWOBJ) /* Rename the current log */
MONMSG MSGID(CPFA0A0) EXEC(DO) /* Check to see if object already exists */
CHGVAR VAR(&COUNT) VALUE(&COUNT + 1)
CHGVAR VAR(&CHARCOUNT) VALUE(&COUNT)
CHGVAR VAR(&NEWOBJ) VALUE('log' *CAT &DATE *CAT '_' *CAT &CHARCOUNT *CAT '.NSF')
GOTO RENAMELOG
ENDDO
RENAMEDLOG:
RNM OBJ(domlog.nsf) NEWOBJ(&NEWOBJ2) /* Rename the current domlog.nsf */
MONMSG MSGID(CPFA0A9) /* Object does not exist */
MONMSG MSGID(CPFA0A0) EXEC(DO) /* Check to see if object already exists */
CHGVAR VAR(&COUNT) VALUE(&COUNT + 1)
CHGVAR VAR(&CHARCOUNT) VALUE(&COUNT)
CHGVAR VAR(&NEWOBJ2) VALUE('domlog' *CAT &DATE *CAT '_' *CAT &CHARCOUNT *CAT '.NSF')
GOTO RENAMEDLOG
ENDDO
/* Submit jobs to run maintenance on indirect file this syntax allows you to define a particular job queue to use rather than the default of QBATCH as the functionality to select the job queue is not available until 8.5.2 */
SBMJOB CMD(RUNDOMCMD SERVER(&SERVERNAME) CMD(CALL PGM(FIXUP) PARM('-j' 'adminfiles.ind')) +
BATCH(*NO)) JOB(FIXUP) JOBQ(MYLIB/DOMMAINT) ALWMLTTHD(*YES) /* Submit fixup task */
MONMSG MSGID(CPF0000)
SBMJOB CMD(RUNDOMCMD SERVER(&SERVERNAME) CMD(CALL PGM(COMPACT) PARM('-c' 'adminfiles.ind')) +
BATCH(*NO) JOBQ(MYLIB/DOMMAINT)) JOB(COMPACT) ALWMLTTHD(*YES)
/* Submit compact task The -i (ignore errors) parameter is optional. */
MONMSG MSGID(CPF0000)
SBMJOB CMD(RUNDOMCMD SERVER(&SERVERNAME) CMD(CALL PGM(UPDALL) PARM('adminfiles.ind' '-r')) +
BATCH(*NO)) JOB(UPDALL) JOBQ(MYLIB/DOMMAINT) ALWMLTTHD(*YES) /* Submit updall task */
MONMSG MSGID(CPF0000)
SBMJOB CMD(STRDOMSVR SERVER(&SERVERNAME)) JOB(STRDOMSVR) JOBQ(MYLIB/DOMMAINT) /*Submit job to restart the server */
MONMSG MSGID(CPF0000)
END:
DLCOBJ OBJ((QUSRNOTES/&SUBSYSTEM *SBSD *EXCL)) /*Release lock on subsystem in order to allow server to restart */
MONMSG MSGID(CPF0000)
ENDPGM