3

I am trying write a script to delete old log files in \var\log\applog\nmon on my AIX system. We usually get alerts that the file system is almost full and at the moment delete old files by hand. So basically what i am looking for is a script that I can schedule in a cron job . This script should keep logs for two months and delete the rest.

There are two files I don't want to be deleted: .profile and .sh_history.

I tried this command:

find nmon -mtime  +60 -type f -not -name ".profile" -not -name ".sh_history" –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.

I tried above command but it gave me this error:

find: 0652-017 -not is not a valid option.

1 Answer 1

2

POSIX does not specify -not, so I guess AIX find does not implement it. You will want to use ! to negate an expression, e.g.

! -name .sh_history

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .