Per archiviare file, ad esempio file di log, si può usare il comando find; ad esempio per storicizzare tutti i file più vecchi di n giorni si può usare la seguente sintassi:
find . -type f -ctime +<n> -exec tar –remove-files -rf <nome_archivio>.tar {} \; && zip <nome_archivio>.tar.zip <nome_archivio>.tar && rm -f <nome_archivio>.tar
Nota dalla pagina man di find:
“n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least
two days ago”
Commenti