Automatically delete or move to another folder, files older than X days [Linux / SSH Commands]
Automatically delete or move to another folder, files older than X days [Linux / SSH Commands]
Nenumarate sunt choice and CONTROLS in linux, si cred ca as fi capiat daca nu aveam optiune sa mut dintr-un folder in altul niste fisiere mai vechi de 120 zile.
Iata cum putem muta niste fisiere mai vechi de X zile :
Comenzi via SSH :
find /home/cale/fisiere* -mtime +120 -exec mv /noua/destinatie/ {} \;
Daca dorim sa stergem toate fisirele mai vechi de 30 de zile, dintr-un folder …
find /cale/fisiere* -mtime +30 -exec rm -f {} \;
Trebuie sa lasati neaparat spatii intre -mtime, numarul zilelor, -exec (linie comanda continua) , rm (comanda de stergere – remove) , argumentul ” -f ” (force delete) , {} si \;.
Este posibil ca pe unele distributii de linux, “-f” sa nu functioneze. Eliminati acest argument din linie si totul va fi ok.
*Testat pe CentOS 5.3 (Final).
Automatically delete or move to another folder, files older than X days [Linux / SSH Commands]
What’s New
About Stealth L.P.
Founder and editor Stealth Settings, din 2006 pana in prezent. Experienta pe sistemele de operare Linux (in special CentOS), Mac OS X , Windows XP > Windows 10 si WordPress (CMS).
View all posts by Stealth L.P.You may also be interested in...
2 thoughts on “Automatically delete or move to another folder, files older than X days [Linux / SSH Commands]”
why does that command also delete the folder itself? I wish you would just delete the content! is there a solution? Thank you
I understand that you have several files in folders and just want to move the files. The folders remain intact. Correct? (GTrs).