在AIX中删除旧的日志文件 [英] Delete old log files in AIX

查看:474
本文介绍了在AIX中删除旧的日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个脚本来删除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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆