by

2

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]

2

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 stergereremove) , 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]

You may also be interested in...

Linux Auto ?

sysadmin Source Code is Free Speech And rm -rf *, does it want to be for all radar devices? Aaaa... there are signs on the face...
Continue reading

2 thoughts on “Automatically delete or move to another folder, files older than X days [Linux / SSH Commands]

  1. Fabrizio says:

    why does that command also delete the folder itself? I wish you would just delete the content! is there a solution? Thank you

    1. Stealth says:

      I understand that you have several files in folders and just want to move the files. The folders remain intact. Correct? (GTrs).

Leave a Reply

Your email address will not be published. Required fields are marked *