KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Using .bat-scripts in "Execute external program" a

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Library
View previous topic :: View next topic  
Author Message
Dubolomov



Joined: 01 Jun 2006
Posts: 214
Location: Russia

PostPosted: Fri Feb 16, 2007 4:03 am    Post subject: Using .bat-scripts in "Execute external program" a Reply with quote

This is example of how to use bat-files with macro variables as command line parameters.

I have all log-files of HostMonitor in "C:\Logs\" folder. In "Log setting" option i'm use log format as a text file with "C:\Logs\%yyyymmdd%--log.txt" filename so there are new log files create every night at 0:00am:
C:\Logs\20070216--log.txt
C:\Logs\20070215--log.txt
C:\Logs\20070214--log.txt
C:\Logs\20070213--log.txt
...
I would like to have logs for last week but to be on the safe side i archiving all older logs in "C:\Backup\" folder using winzip. In Scheduler option of HM i created task named "Archive Logs and HM" with Execute external program action that executes daily at 0:10am. Option of this action has script file:
"C:\Program Files\HostMonitor5\Scripts\Archive.bat" %yyyymmdd[-8d]% %yyyymmdd[-1d]% %yyyymmdd% %hhnn%
This is start .bat-file with parameters.

Bat-file has a few commands:
@echo %1 - Date of files for deleting (yyyymmdd[-8d]).
@echo %2 - Yesterday (yyyymmdd[-1d]).
@echo %3 - Today (yyyymmdd).
@echo %4 - Real Time (hhnn).

@if '%1'=='' goto quit
@if '%2'=='' goto quit
@if '%3'=='' goto quit
@if '%4'=='' goto quit

del /Q "C:\Logs\*%1--log.txt" > "C:\Logs\SysLog\Archive--%3_%4.log"
"C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc "C:\BackUp\HostMonitor_Logs_%2__(created_at__%3_%4).zip" "C:\Logs\*%2--log.txt" >> "C:\Logs\SysLog\Archive--%3_%4.log"
"C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc "C:\BackUp\HostMonitor_%3__(created_at__%3_%4).zip" "C:\Program Files\HostMonitor5" >> "C:\Logs\SysLog\Archive--%3_%4.log"

:quit
exit


So in "C:\Backup\" folder i have archive of all log-files and full backup of HostMonitor with it's settings.
It's possible to add in bat-file script commands for copying all archives on any network drive for fully safety of backup. I'm using external service for this.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index