OS/LINUX
[펌] 일정 시간동안 접근이 없는 파일 삭제하기 [ok]
tornado
2009. 8. 4. 10:59
출처 : http://onlybible.tistory.com/1202
tmpwatch 라는 명령
1. 이런 파일이 있다.
[root@testguk guk]# ll
합계 424
-rw-r--r-- 1 root root 10 9월 23 15:40 1.txt
-rw-r--r-- 1 root root 357961 9월 18 17:31 1221626338-metabbs-0.11.tar.tar
-rw------- 1 root root 1052 9월 17 02:41 anaconda-ks.cfg
-rw-r--r-- 1 root root 104 9월 22 18:37 array_pop.php
-rw-r--r-- 1 root root 82 9월 22 18:40 array_push.php
-rw-r--r-- 1 root root 106 9월 23 14:19 array_shift.php
-rw-r--r-- 1 root root 210 9월 23 14:33 array_unique.php
-rw-r--r-- 1 root root 96 9월 23 14:23 array_unshift.php
-rw-r--r-- 1 root root 344 9월 19 16:21 asort.php
-rw-r--r-- 1 root root 13333 9월 17 02:41 install.log
-rw-r--r-- 1 root root 2551 9월 17 02:41 install.log.syslog
-rw-r--r-- 1 root root 148 9월 19 16:06 ksort.php
-rw-r--r-- 1 root root 63 9월 22 18:32 rsort.php
-rw-r--r-- 1 root root 200 9월 19 15:33 shuffle.php
-rw-r--r-- 1 root root 298 9월 19 15:48 sort.php
2. 24시간 이후로 접근이 없는 파일들 삭제
[root@testguk guk]# tmpwatch --atime 24 ./
[root@testguk guk]# ll
합계 28
-rw-r--r-- 1 root root 10 9월 23 15:40 1.txt
-rw-r--r-- 1 root root 104 9월 22 18:37 array_pop.php
-rw-r--r-- 1 root root 82 9월 22 18:40 array_push.php
-rw-r--r-- 1 root root 106 9월 23 14:19 array_shift.php
-rw-r--r-- 1 root root 210 9월 23 14:33 array_unique.php
-rw-r--r-- 1 root root 96 9월 23 14:23 array_unshift.php
-rw-r--r-- 1 root root 63 9월 22 18:32 rsort.php
간단하네.
tmpwatch 라는 명령
1. 이런 파일이 있다.
[root@testguk guk]# ll
합계 424
-rw-r--r-- 1 root root 10 9월 23 15:40 1.txt
-rw-r--r-- 1 root root 357961 9월 18 17:31 1221626338-metabbs-0.11.tar.tar
-rw------- 1 root root 1052 9월 17 02:41 anaconda-ks.cfg
-rw-r--r-- 1 root root 104 9월 22 18:37 array_pop.php
-rw-r--r-- 1 root root 82 9월 22 18:40 array_push.php
-rw-r--r-- 1 root root 106 9월 23 14:19 array_shift.php
-rw-r--r-- 1 root root 210 9월 23 14:33 array_unique.php
-rw-r--r-- 1 root root 96 9월 23 14:23 array_unshift.php
-rw-r--r-- 1 root root 344 9월 19 16:21 asort.php
-rw-r--r-- 1 root root 13333 9월 17 02:41 install.log
-rw-r--r-- 1 root root 2551 9월 17 02:41 install.log.syslog
-rw-r--r-- 1 root root 148 9월 19 16:06 ksort.php
-rw-r--r-- 1 root root 63 9월 22 18:32 rsort.php
-rw-r--r-- 1 root root 200 9월 19 15:33 shuffle.php
-rw-r--r-- 1 root root 298 9월 19 15:48 sort.php
2. 24시간 이후로 접근이 없는 파일들 삭제
[root@testguk guk]# tmpwatch --atime 24 ./
[root@testguk guk]# ll
합계 28
-rw-r--r-- 1 root root 10 9월 23 15:40 1.txt
-rw-r--r-- 1 root root 104 9월 22 18:37 array_pop.php
-rw-r--r-- 1 root root 82 9월 22 18:40 array_push.php
-rw-r--r-- 1 root root 106 9월 23 14:19 array_shift.php
-rw-r--r-- 1 root root 210 9월 23 14:33 array_unique.php
-rw-r--r-- 1 root root 96 9월 23 14:23 array_unshift.php
-rw-r--r-- 1 root root 63 9월 22 18:32 rsort.php
간단하네.