I have been struggling with this for a few days and need some divine assistance.
I have a requirement to read a cifs share folder, any files in the folder/subfolder(s) that are more than six days old need to be zipped and moved to an achieve location then removed ... caveat is that the integrity of the folder structure must be maintained even if folder is empty. NO folder deletion!!
Oh, and some folder names have spaces in them so have to allow for that.
here is what I have tried thus far:
Code:
find /mnt/bus_pc/phoesb04/Salvage -type f -mtime +6 | xargs -d "\n" tar -czvPf /mnt/midtier_logsarchive/phoesb04/Salvage/Salvage_`date -d "yesterday" +%Y%m%d`.tgz
seems to work on the spaces in the folder, however, it only tar/zip the last folder processed.
I copied the cifs to local to work on and see if it was something to do with the cifs being actively connected to Biztalk environment.
Code:
tar -czvPf ~/PolicyService_`date -d "yesterday" +%Y%m%d`.tgz /tmp/bus_pc/phoesb04/PolicyService/
works!!
but when I ran the above script pointing to the local copy, same results as when on the cifs.
Code:
find /tmp/bus_pc/phoesb04/PolicyService -type f -mtime +6 | xargs -d "\n" tar -czvPf ~/PolicyService_`date -d "yesterday" +%Y%m%d`.tgz;
only last dir processed
Code:
find /mnt/bus_pc/phoesb04/PolicyService -type f -mtime +6 -exec tar -czvPf ~/PolicyService_`date -d "yesterday" +%Y%m%d`.tgz {} \;
only last dir processed
shouldn't be this difficult so what am I missing here. Thank you!