728x90
728x90
[webMethods 자바 서비스로 log파일 삭제하기]
find ./ -type f -mtime +90 -name * -exec rm -rf {} ;
webMethods 자바 구현한 후 실행해보면 실제 로그파일들이 삭제된 것을 확인할 수 있다.
| IDataCursor pipelineCursorInput = pipeline.getCursor(); String[] dirList = IDataUtil.getStringArray( pipelineCursorInput, "dirList"); //삭제할 로그 디렉토리 String interval = IDataUtil.getString( pipelineCursorInput, "interval" ); //interval 이전 데이타 String fileLevel = IDataUtil.getString( pipelineCursorInput, "fileLevel" ); //파일별 삭제 여부 String filePattern = "*"; if(fileLevel.equals("true")) { filePattern = IDataUtil.getString( pipelineCursorInput, "filePattern" ); //파일 및 파일패턴 } pipelineCursorInput.destroy(); //String dirHome = System.getProperty("user.dir"); //삭제할 로그 디렉토리 //String interval = "+60"; //60일 이전 데이타 String message = "Error"; try { Runtime runtime = Runtime.getRuntime(); if(fileLevel.equals("true")) { for(int i=0; i<dirList.length; i++) { runtime.exec( "find " + dirList[i] + " -type f -mtime " + interval + " -name " + filePattern + " -exec rm -rf {};")) Thread.sleep(1000); } } else { for(int i=0; i<dirList.length; i++) { runtime.exec( "find " + dirList[i] + " -type f -mtime " + interval + " -exec rm -rf {} ;")) Thread.sleep(1000); } } message = "Success"; } catch(Exception e) { } IDataCursor pipelineOutput = pipeline.getCursor(); pipelineOutput.insertAfter("message", message); pipelineOutput.destroy(); |
728x90
반응형
'IT 이모저모' 카테고리의 다른 글
| [webMethods] SSL debug 작업을 위한 환경 설정 (0) | 2021.02.10 |
|---|---|
| [webMethods] WS-Security 이해 (0) | 2021.02.10 |
| EDI(RosettaNet) 표준 프로세스 흐름도 (0) | 2021.02.10 |
| 업무별 EDI Message 정의 (EDIFACT, RosettaNet, X12) (0) | 2021.02.08 |
| 소스 코드 시각화를 통해 자료형 개념과 변수 이해하기 (0) | 2021.02.08 |
댓글