Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 删除AIX中的旧日志文件_Shell_Unix_Find_Aix - Fatal编程技术网

Shell 删除AIX中的旧日志文件

Shell 删除AIX中的旧日志文件,shell,unix,find,aix,Shell,Unix,Find,Aix,我正在尝试编写一个脚本来删除AIX系统中path\var\log\applog\nmon中的旧日志文件。我们通常会收到这样的警报:文件系统几乎已满,我们所做的只是转到路径并删除旧的日志文件。所以基本上我要找的是我可以在corn job中安排的脚本。此脚本应保留日志两个月,并删除其余日志 还有这两个文件,我不想删除 命名:.profile和.sh_历史 我试过这个命令: find ./My_Dir -mtime +60 -type f –delete 它工作得很好,但它也删除了我前面提到的两个

我正在尝试编写一个脚本来删除AIX系统中path\var\log\applog\nmon中的旧日志文件。我们通常会收到这样的警报:文件系统几乎已满,我们所做的只是转到路径并删除旧的日志文件。所以基本上我要找的是我可以在corn job中安排的脚本。此脚本应保留日志两个月,并删除其余日志

还有这两个文件,我不想删除

命名:.profile和.sh_历史

我试过这个命令:

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
顺便说一下,要删除旧文件,最好使用放大镜


根据您的评论更新:

查找:0652-017-不是有效选项

然后使用这个:
-名称“文件的名称”


非常感谢。上面写着
find:0652-017-not是无效的选项。
查看我的更新答案@DeepeshShetty,试试
而不是
-不是

find ./My_Dir \
    -mtime  +60 \
    -type f \
    ! -name ".profile" \
    ! -name ".sh_history" –delete