Fun writing a maintenance script

Today, I had quite a bit of fun writing and debugging a weekly maintenance script.

I use this on all of my normal servers, but today, fine tuning this for a partitioned Domino server became a little bit of a challenge.
Tailoring all of the command line input from each of the different commands took a little bit of research.

Thanks to for Jean-Yves Riverin’s FAQ article on NSD
Frequently asked question – How to analyze Notes/Domino NSDs?

I also found other bits on the input method for nserver.exe, ncompact.exe, and nfixup.exe on the Notes/Domino 6 and 7 forum:

I should also say that I’ve been using this for years, but added the drop all and dbcache flush to help the server shutdown quicker. I got those from the maintenance script over at openntf.org. The rest of it, I came up with myself over the years.

Here is a .zip file which contains the 3 batch files I use. satjob.bat is called by the AT.exe scheduler in Windows 2003. This .zip file contains the batch maintenance for a NON-PARTITIONED server.
maintain.zip

The code below are the modifications for partitioned servers.


HOSTNAME
@REM (NOW) PUTS A TIMESTAMP IN THE MAINTAIN.LOG
@echo %date% %time% **************************
@echo %date% %time% Start Saturday Maintenance
@echo %date% %time% **************************

@REM drop users and cache
@c:
@cd \lotus\domino
NSERVER.EXE "=E:\Lotus\directory\notes.ini" -c "drop all"
NSERVER.EXE "=E:\Lotus\notesmon\notes.ini" -c "drop all"
NSERVER.EXE "=E:\Lotus\notessmtp0\notes.ini" -c "drop all"
NSERVER.EXE "=E:\Lotus\directory\notes.ini" -c "dbcache flush"
NSERVER.EXE "=E:\Lotus\notesmon\notes.ini" -c "dbcache flush"
NSERVER.EXE "=E:\Lotus\notessmtp0\notes.ini" -c "dbcache flush"

@REM Stop the Domino service
NET STOP "Lotus Domino Server (lotusdirectory)"
NET STOP "Lotus Domino Server (lotusnotesmon)"
NET STOP "Lotus Domino Server (lotusnotessmtp0)"

@REM PAUSE 5 MINUTES TO GIVE TIME FOR THE DOMINO TASKS TO SHUTDOWN PROPERLY
TIMEOUT 300

@REM run nsd kill to terminate any tasks that haven't shut down
@C:
@cd\lotus\domino\
NSD.EXE -ini E:\Lotus\directory\notes.ini -kill
NSD.EXE -ini E:\Lotus\notesmon\notes.ini -kill
NSD.EXE -ini E:\Lotus\notessmtp0\notes.ini -kill

@REM (ECHO ON) LOGS ANY ERRORS/DIALOG IN THE FOLLOWING SECTIONS TO MAINTAIN.LOG
ECHO ON

@REM THE SECTION RUNS FIXUP/COMPACT ON NAMES.NSF, STATREP.NSF, and DC.NSF
@REM WHILE THE DOMINO SERVER IS DOWN
@C:
@cd\lotus\domino
nfixup e:\lotus\directory\names.nsf =E:\Lotus\directory\notes.ini
nfixup e:\lotus\directory\statrep.nsf =E:\lotus\directory\notes.ini
nfixup e:\lotus\directory\dc.nsf =E:\lotus\directory\notes.ini
nfixup e:\lotus\notesmon\names.nsf =E:\Lotus\notesmon\notes.ini
nfixup e:\lotus\notesmon\statrep.nsf =E:\lotus\notesmon\notes.ini
nfixup e:\lotus\notessmtp0\names.nsf =E:\Lotus\notessmtp0\notes.ini
nfixup e:\lotus\notessmtp0\statrep.nsf =E:\lotus\notessmtp0\notes.ini
@cd\

@E:
@cd\lotus\directory\
ncompact e:\lotus\directory\names.nsf
ncompact e:\lotus\directory\statrep.nsf
ncompact e:\lotus\directory\dc.nsf
@cd\lotus\notesmon\
ncompact e:\lotus\notesmon\names.nsf
ncompact e:\lotus\notesmon\statrep.nsf
@cd\lotus\notessmtp0\
ncompact e:\lotus\notessmtp0\names.nsf
ncompact e:\lotus\notessmtp0\statrep.nsf
@cd\

@REM THIS DELETES ALL DIRECTORIES IN EVERY SUBDIRECTORY UNDER c:\lotus\domino\data
@REM THAT HAVE THE .FT EXTENSION
@echo %date% %time% Full Text Index Maintenance
@E:
@cd\lotus\directory
pushd %1
for /D /R %%i in (*.ft) do rd "%%i" /s /q
popd
@echo %date% %time% DIRECTORY Full Text Index Maintenance completed
@cd\

@cd\lotus\notesmon
pushd %1
for /D /R %%i in (*.ft) do rd "%%i" /s /q
popd
@echo %date% %time% NOTESMON Full Text Index Maintenance completed
@cd\

@cd\lotus\notessmtp0
pushd %1
for /D /R %%i in (*.ft) do rd "%%i" /s /q
popd
@echo %date% %time% NOTESSMTP0 Full Text Index Maintenance completed
@cd\

@REM THIS SECTION DELETES THE DTF FILES THAT ARE TEMP FILES CREATED BY DOMINO
@REM THESE ARE CREATED IN THE C:\windows\TEMP DIRECTORY BECAUSE OF THE NOTES.INI VARIABLE
@REM View_Rebuild_Dir=c:\windows\temp or because c:\windows\temp is set in the environment
@REM variables as the system temp directory

@echo %date% %time% Delete DTF Files
@c:
@cd \windows\temp
del /s /q *.dtf
del /s /q *.tmp
@cd \temp
del /s /q *.dtf
del /s /q *.tmp
@cd\
@echo %date% %time% DELETE DTF files Complete

@echo %date% %time% deleting any DOMINO data directory temp files
@e:
@cd\
del /s /q *.tmp
@echo %date% %time% delete DOMINO data directory temp files Complete

@echo %date% %time% deleting console log files older than 60 days
Forfiles -p e:\lotus\directory\ibm_technical_support -s -m console*.* -d -60 -c "cmd /c del /q @path"
Forfiles -p e:\lotus\notesmon\ibm_technical_support -s -m console*.* -d -60 -c "cmd /c del /q @path"
Forfiles -p e:\lotus\notessmtp0\ibm_technical_support -s -m console*.* -d -60 -c "cmd /c del /q @path"
@echo %date% %time% finished deleting console log files

@REM THIS SECTION LOGS AN EVENT TO THE wINDOWS EVENT LOG
@c:
@cd\
eventcreate /L APPLICATION /T INFORMATION /SO maintain.bat /id 999 /d "Domino Weekly Maintenance Completed"

4 Responses to “Fun writing a maintenance script”

  • I run ncompact on the client side but i am having an issue that does not allow me to set the script to run on its own. For one reason or other, i need to run ncompact in multiple directories (3 to be exact). ncompact’s arugments allows for one directory (recursive) at a time.
    So fine, my batch file loops trhough the directories (the base ones) and runs the 3 or as many as i need. The problem is the password.
    Because i am running this on the client side (for the client copy) i need to enter the password, and i cannot find ANY possible way to enter it just once, such as getting it when first running (via set /P) and passing it as an argument.
    Do you know of ANY way (out side of single client logon, which may do it but i don’t want to use), that i can pass the password as an argument of ncompact?

  • david says:

    I’m afraid that I don’t. Possibly there is a way to do it with visual basic, but I’m really not sure about that.

    It sounds interested though, what exactly are you trying to do?

  • Wayne says:

    This is great. I have a few ideas of my own, but I’m curious to know how you start the domino service after maintenance is complete. Thanks!

  • david says:

    I typically just reboot windows at this point and we have Domino set to start up automatically as a service.

    If you download the maintain.bat file up at the top of the post and unzip it you will find 3 batch files.

    satjob.bat
    maintain.bat
    reboot.bat

    Call satjob.bat with your scheduler, and the rest will happen automatically.

    Look at the contents of reboot.bat to see how to re-boot Windows machines.

    However, if you just want to restart the service, you can do it with either of these commands:
    NET START “Lotus Domino Server (lotusdirectory)”
    NET START “Lotus Domino Server (lotusnotesmon)”
    NET START “Lotus Domino Server (lotusnotessmtp0)”

Leave a Reply

Consulting

I'm currently available
for Lotus Notes / Domino consulting engagements.

LinkedIn

Connect with me:

LinkedIn

Advertisement
Advertisement
Categories