프로그램/linux2014. 11. 1. 13:42

리눅스 find 명령어를 이용해서 특정용량(예>0byte)의 파일을 찾아서 삭제할 수 있다.

 

사용법>

]# find 경로 -size 용량

 

 

사용 예>

0byte 용량의 파일 찾기

]# find . -size 0

 

 

 

사용 예>

0byte 용량의 파일 찾아서 삭제하기

]# find . -size 0 -exec rm -rf {} \;

 

]# ll

 

Posted by 은둔고수
프로그램/linux2014. 11. 1. 13:06

리눅스에서 로그 파일이나 원하는 파일을 삭제하지 않고 용량만 0byte로 만들고 싶다면

cat /dev/null 을 이용해서 0byte로 만들 수 있다.

 

사용법>

]# cat /dev/null > 0byte 처리할 파일

 

 

사용 예>

dummy-host.example.com-access_log 파일을 삭제하지 않고 용량을 0byte로 만들기

]# ll

 

]# cat /dev/null > /usr/local/apache2/logs/dummy-host.example.com-access_log

 

]# ll

dummy-host.example.com-access_log 파일이 0byte로 처리된 것을 확인할 수 있다.

Posted by 은둔고수