반응형
n일 경과한 로그파일 검색
[marsland@www:/usr/local/tomcat/service/logs/web] find . -type f -mtime +6
./allat.log.2020-03-18
./allat.log.2020-03-23
./allat.log.2020-04-07
./root.log.2020-02-21
./allat.log.2020-03-19
./root.log.2020-04-15
./root.log.2020-02-22
./allat.log.2020-03-24
./root.log.2020-04-09
./root.log.2020-02-23
./allat.log.2020-02-21
./root.log.2020-03-23
./root.log.2020-04-10
./root.log.2020-02-24
./allat.log.2020-03-25
./root.log.2020-04-11
검색된 결과 삭제
[marsland@www:/usr/local/tomcat/service/logs/web] find . -type f -mtime +6 -exec rm -f {} \;
여러 폴더 로그 삭제
drwxrwxr-x 12 www www 4096 2월 19 11:39 tomcat-marsland-admin2/
drwxrwxr-x 10 www www 4096 2월 19 11:37 tomcat-marsland-m2/
drwxrwxr-x 10 www www 4096 2월 19 11:34 tomcat-marsland-web2/
[marsland@www:/usr/local/tomcat] find /usr/local/tomcat/*/logs -type f -mtime +6 -exec rm -f {} \;
crontab 등록
[marsland@www:/usr/local/tomcat] crontab -e
### 6 days ago old log rm ###
### 매일 6시 0분에 동작 ###
0 6 * * * find /usr/local/tomcat/*/logs/ -type f -mtime +6 -exec rm -f {} \;
[marsland@www:/usr/local/tomcat] crontab -l
### 6 days ago old log rm ###
0 6 * * * find /usr/local/tomcat/*/logs/ -type f -mtime +6 -exec rm -f {} \;
[marsland@www:/usr/local/tomcat]
반응형
'Programming > CentOS' 카테고리의 다른 글
[CentOS] 프로세스 우아하게 죽이기 (graceful shutdown process) (0) | 2021.07.16 |
---|---|
[CentOS] JAVA 설치 (0) | 2021.07.16 |