用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参数后面是要执行的命令;{}表示当前目录。