Thursday 22 October 2009

Autorotate and renaming the files as for date with batch script and vbscript (logrotate)

It explained to write the script for rotate the log files and delete files older 30 days. these scripts taken from other people sites and modified for this convenience.
For this script you need FDATE program to mention the date format to insert in to the file name.
and here used the VB script to compare dates, creation and today date and deleting. So many people written the batch script for this with environment variables in DOS. I thought that script is very long and little bit confusing.

Here is the batch script for rename the log files


@echo off
Rem the below line come in to the "c:\>" this file kept in C drive
cd\
rem stoping the rsync service
Net stop rsyncd


for /f "tokens=1,2 delims=/\-." %%f in ('FDATE /Ff /Occyymmdd') do REN c:\rsync\rsyncd.log %%f%%g.log
gzip -9 c:\rsync\*.*

c:\temp\test.vbs



Net start rsyncd

pause

No comments:

Post a Comment