I'm looking for a script to backup and remove the db2diag.log file. I saw one, but can't make it work. I'm new to bat file creations. Thanks!
Rob

Here it is, but it doesn't work when I try to run it.

@echo off
::---------------------------------------------------------------------------::
:: This is a Windows Shell Script to archive the db2
diagnostic log file. It :: assumes the db2diag.log file
is in the default diagnostic log directory :: and
renames it to db2diag.YYYYMMDD.log It also deletes all
but the last :: seven (7) of these diagnostic log
archives.
::---------------------------------------------------------------------------::
set script_name=%~n0 set script_log=%~n0.log set
script_ver=1.0 set DB2INSTANCE=DB2 set
DB2DATABASE=SAMPLE

title %script_name% v%script_ver% echo %script_name%
v%script_ver% started on %date% at %time%


::---------------------------------------------------------------------------::
:: Set Script Date Variable
::---------------------------------------------------------------------------::
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set script_date=%%l%%j%%k
)


::---------------------------------------------------------------------------::
:: Set DB2 Path Variable
::---------------------------------------------------------------------------::
if not defined db2path (
for /F %%i in ('db2set db2path') do (set db2path=%%i)
echo %script_name% v%script_ver% set db2path as %db2path% )


set db2diag_path=%db2path%\%db2instance%
echo
%script_name% v%script_ver% set db2diag_path to
%db2diag_path%

set db2diag_file=%db2diag_path%\db2diag.log
echo
%script_name% v%script_ver% set db2diag_file to
%db2diag_file%


::---------------------------------------------------------------------------::
:: Archive DB2 Diagnostic Log File
::---------------------------------------------------------------------------::
echo %script_name% v%script_ver% archiving
%db2diag_file% to db2diag.%script_date%.log ren
%db2diag_file% db2diag.%script_date%.log 2>
%script_log% if not %errorlevel% == 0 ( echo ERROR:
Unable to archive %db2diag_file% to
db2diag.%script_date%.log, RC=%errorlevel% type
%script_log% )


::---------------------------------------------------------------------------::
:: Delete DB2 Diagnostic Log Archives 7 days or older
::---------------------------------------------------------------------------::
set db2diag_arch=%db2diag_path%\db2diag.*.log for /f
"skip=7" %%i in ('dir %db2diag_arch% /b /o:-n') do (
echo %script_name% v%script_ver% purging %%i del
%db2diag_path%\%%i 2> %script_log% if not
%errorlevel% == 0 ( echo ERROR: Unable to delete
archive %%i, RC=%errorlevel% type %script_log% ) )

echo %script_name% v%script_ver% completed on %date% at
%time%