Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.