linux | 톰캣 로그 주기적(crontab )으로 삭제하기
페이지 정보
작성자 100K5 작성일24-03-05 16:15 조회738회 댓글0건관련링크
본문
1. 14일 경과 된 파일을 찾는다. (-ctime : 생성된 시간, -mtime : 수정된 시간)
(톰캣 로그 경로는 환경에 따라 수정 필요)
find /tomcat/logs/ -mtime +14 -exec ls -l {} \;
2. 정상적인 동작을 한다면 쉡 스크립트를 생성하여 하단의 내용을 등록 하고 저장 한다.
vi /tomcat/bin/delete-log.sh
find /tomcat/logs/ -mtime +14 -exec rm -f {} \;
3. 해당 쉘 스크립트 권한 설정
chmod 775 delete-log.sh
4.클론탭 설정(분 시 일 월 요일 쉘스크립트경로)
crontab -e
// 매주 월요일 08시 00분에 실행
0 08 * * 1 /tomcat/bin/delete-log.sh
// 매일 08시 00분에 실행
0 08 * * * /tomcat/bin/delete-log.sh
댓글목록
등록된 댓글이 없습니다.