在AIX中删除旧的日志文件 [英] Delete old log files in AIX
问题描述
同样有这两个文件,我不希望它被删除。
$ b
命名为: .profile和.sh_history
我试过这个命令:
find ./My_Dir -mtime +60 -type f -delete
它工作正常,但它也删除了我前面提到的那两个文件。
我不知道如何处理脚本我可以删除旧的日志文件,但不是这两个文件。
谢谢
您可以使用 -not -name ...
参数:
find ./My_Dir \
-mtime +60 \
-type f \
-not -name.profile\
-not - name.sh_history-delete
顺便说一下,要删除旧文件,最好使用宏伟的 logrotate工具。
更新您的评论:
find:0652-017 - 不是一个有效的选项。
然后使用这个:! -namename_of_file
find ./My_Dir \
-mtime +60 \
-type f \
! -name.profile\
! -name.sh_history-delete
I am trying write a script to delete old log files in path \var\log\applog\nmon in my AIX system. We usually get this alerts that the file system is almost full and all we do is go to the path and delete old log files. So basically what i am looking for is the script that i can schedule in corn job . This script should keep logs for two months and delete the rest .
Again there are these two files i don't want it to be deleted .
Named:.profile and .sh_history
I tried this command :
find ./My_Dir -mtime +60 -type f –delete
It works fine but it also deletes those two file which i mentioned earlier .
I am not sure how to proceed with the script so that i can delete old logs file but not those two files.
Thanks
You can use the -not -name ...
parameter:
find ./My_Dir \
-mtime +60 \
-type f \
-not -name ".profile" \
-not -name ".sh_history" –delete
By the way, to delete old files it is always better to use the magnificient logrotate tool.
Update from your comment:
find: 0652-017 -not is not a valid option.
Then use this: ! -name "name_of_file"
find ./My_Dir \
-mtime +60 \
-type f \
! -name ".profile" \
! -name ".sh_history" –delete
这篇关于在AIX中删除旧的日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!