歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> 關於Unix

AIX下如何刪除某個目錄下日期早於凌晨03:00的文件


用find命令
AIX下如何刪除某個目錄下日期早於凌晨03:00的文件
這些文件每天生成,如何寫sh腳本,讓sh在crontab中計劃執行,定時刪除時間早於03:00的文件
如:
# ls -l
total 34504336
-rwxrwxrwx 1 root system 1073741824 Nov 9 00:40 20051109.001
-rwxrwxrwx 1 root system 1073741824 Nov 9 00:55 20051109.002
-rwxrwxrwx 1 root system 1073741824 Nov 9 01:09 20051109.003
-rwxrwxrwx 1 root system 1073741824 Nov 9 01:22 20051109.004
-rwxrwxrwx 1 root system 1073741824 Nov 9 01:35 20051109.005
-rwxrwxrwx 1 root system 1073741824 Nov 9 01:47 20051109.006
-rwxrwxrwx 1 root system 1073741824 Nov 9 01:59 20051109.007
-rwxrwxrwx 1 root system 1073741824 Nov 9 02:11 20051109.008
-rwxrwxrwx 1 root system 1073741824 Nov 9 02:23 20051109.009
-rwxrwxrwx 1 root system 1073741824 Nov 9 02:34 20051109.010
-rwxrwxrwx 1 root system 1073741824 Nov 9 02:45 20051109.011
-rwxrwxrwx 1 root system 1073741824 Nov 9 02:56 20051109.012
-rwxrwxrwx 1 root system 347865088 Nov 9 03:00 20051109.013
-rwxrwxrwx 1 root system 1073741824 Nov 9 03:12 20051109.014
-rwxrwxrwx 1 root system 1073741824 Nov 9 03:25 20051109.015
-rwxrwxrwx 1 root system 987889664 Nov 9 04:00 20051109.016
-rwxrwxrwx 1 root system 1073741824 Nov 9 08:33 20051109.017
-rwxrwxrwx 1 root system 224329728 Nov 9 08:44 20051109.018
-rwxr-xr-x 1 root system 15 Nov 7 09:17 cache.lck
find /Journal/journal -ctime +1! -name "*[2][0][0][0-9][0-9][0-9][0-9][0-9].[0-9][0-9][0-9]" -exec ls -l {} ;
find /Journal/journal -ctime +1! -name "*[2][0][0][0-9][0-9][0-9][0-9][0-9].[0-9][0-9][0-9]" -exec rm {} ;
在/Journal/journal目錄下查找1天前的文件,並且名字包含"*[2][0][0][0-9][0-9][0-9][0-9][0-9].[0-9][0-9][0-9]" 的文件
-exec參數後面是要執行的命令;{}表示當前目錄。
Copyright © Linux教程網 All Rights Reserved