대개 로그들은 일정 패턴을 가지고 남기는 경우가 많고
특정 시간이나 일자로 복사를 해야 하는 경우가 많은데
여러대의 서버를 하나씩 복사하기 귀찮으니 -_-;
스크립트을 통해 대신 처리 해본다.
기본적인 패턴을 나열 했으니 적당히 고쳐서 쓰면 됨
unzip은 인터넷에 실행 파일 하나로 떠 도는게 있음.
날짜에 따라 구분이 없는 경우 TODAY_COPY랑 분리를 안해도 됨
하지만 용량을 위해서 구분하고 압축 하는 경우가 많으니...
findstr명령어를 통해 특정 패턴에 맞게 추출도 가능은 함
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
IF "%1" == "" GOTO END_A | |
IF "%2" == "" GOTO END_A | |
ECHO 파일 복사 및 생성을 시작합니다. 각 웹서버에 네트워크 연결이 되어 있어야 합니다. | |
@ECHO ON | |
@ECHO OFF | |
SET TODAY=%date:~-10,4%%date:~-5,2%%date:~-2,2% | |
IF "%TODAY%"=="%1" GOTO TODAY_COPY | |
xcopy \\server-01\Logs\%2_%1.log D:\log\%2\%1\server-01\ /s /Y | |
xcopy \\server-02\Logs\%2_%1.log D:\log\%2\%1\server-02\ /s /Y | |
xcopy \\server-03\Logs\%2_%1.log D:\log\%2\%1\server-03\ /s /Y | |
GOTO UNZIP | |
:TODAY_COPY | |
@ECHO ON | |
xcopy \\server-01\Logs\%2_%1.log D:\log\%2\%1\server-01\ /s /Y | |
xcopy \\server-02\Logs\%2_%1.log D:\log\%2\%1\server-02\ /s /Y | |
xcopy \\server-03\Logs\%2_%1.log D:\log\%2\%1\server-03\ /s /Y | |
GOTO OPENFOLDER | |
@rem GOTO FINDSTR | |
:UNZIP | |
call unzip -u D:\log\%2\%1\server-01\*.zip -d D:\log\%2\%1\server-01\ | |
call unzip -u D:\log\%2\%1\server-02\*.zip -d D:\log\%2\%1\server-02\ | |
call unzip -u D:\log\%2\%1\server-03\*.zip -d D:\log\%2\%1\server-03\ | |
GOTO OPENFOLDER | |
@rem GOTO FINDSTR | |
:FINDSTR | |
d: | |
cd D:\log\%2\%1\ | |
findstr /s /i "FIND_STRING" *.* > D:\log\logStatic\%2_%1_FindLogString.txt | |
cd D:\log\logStatic\%2\%1\ | |
GOTO OPENFOLDER | |
notepad D:\log\logStatic\%2_%1_FindLogString.txt | |
:OPENFOLDER | |
explorer D:\log\%2\%1\ | |
GOTO END | |
@ECHO OFF | |
GOTO END | |
:END_A | |
ECHO 에러) 복사할 파일 날짜를 입력하세요. | |
ECHO usage) copylog date_part_of_file ex) copylog 2016-06-19 LogPatternName | |
@ECHO ON | |
:END |
'IT' 카테고리의 다른 글
[Dos][Batch] wget api 호출 테스트 해보기 (0) | 2016.07.31 |
---|---|
[curl] curl get 호출 해보기 (0) | 2016.07.30 |
[Java][jstl] form tag select option (0) | 2016.05.07 |
[iOS] XCode Swift UIColor Extention (0) | 2016.03.13 |
맥 Mac osx 터미널 디렉토리 색상 설정 (0) | 2015.12.20 |