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:By the way, to delete old files it is always better to use the magnificient logrotate tool.
Update from your comment:
Then use this:
! -name "name_of_file"