Thank you gwootton for prompt response..
Actually I found below find commands...but
find /sas/install/config/Lev1/Logs -maxdepth 1 -mtime +60 -type f -exec mv "{}" /backup \; find /backup -maxdepth 1 -mtime +180 -type f -exec rm "{}" \;
find /sas/install/config/Lev1/Web/WebServer/logs -maxdepth 1 -mtime +60 -type f -exec mv "{}" /sashome/M6_install/config/Lev1/Web/WebServer/logs/backup_062821 \; find /sashome/M6_install/config/Lev1/Web/WebServer/logs/backup_062821 -maxdepth 1 -mtime +180 -type f -exec rm "{}" \;
find /sas/install/config/Lev1/Web/Logs/SASServer1_1 -maxdepth 1 -mtime +60 -type f -exec mv "{}" /sashome/M6_install/config/Lev1/Web/Logs/SASServer1_1/backup_062821 \; find /sashome/M6_install/config/Lev1/Web/Logs/SASServer1_1/backup_062821 -maxdepth 1 -mtime +180 -type f -exec rm "{}" \;
but am looking for the script with adding some email messages for each action taking place. find in conjunction with mv or rm. But for every find there must be a communication to sas admin telling what has been done
Script servse the purpose in this case but what is missing the communication and not dealing with the error condition like a situation when there's not enough disk space on the target file system. And also not handling overwriting the file names when moving the file from sources to destinations
I need below three things :
1)need to add comments line for each find command action 2)need to add send email for each action 3) need to add one more condition--- compression of the file after a month 4) also u need to know the size of the file moved from source to destination
and also I need to have a new file name when moving from source to destination
The new name is necessary to avoid overwriting. The new naming convention should reflect the old name + server name + date of the activity,This is necessary since every things goes to same file system And names has to be unique to avoid overwriting
Basically it is a rotation of the log files to compress after a month , followed by moving and then removing
If u do not give new name, it will overwriting in the old file,It us good practice to have any new file with name having time stamp.
That way when we need those files in future we can track them easily
So new file name=old name.time stamp
The whole idea of this practice is that I will be retaining these log file for a year is that i may need them
My opinion is each month. In each folder, compress, tar the previous month's logs
Example; xxxlog-202106.tar.zip at the end of this month
Compression stays in side the source side
After the compression the directory will create a one single file which will be moving after three months
One single file will be Xxxxlog-20320631.targz And this file will be moved to /log at the end of December And should have the same name as it is
But should go to the directory for the relevant server inside /log /log/metadata/xxxlog202106.targz
Would really appreciate your help
... View more