Slett automatisk eller flytt til en annen mappe, filer eldre x -dag [Linux / SSH -kommandoer]

Nenumarate sunt valg og KONTROLLER 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,-fsa nu functioneze. Eliminati acest argument din linie si totul va fi ok.

*Testat pe CentOS 5.3 (Final).

Grunnlegger og redaktør 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).

Hjem Din kilde til IT -opplæringsprogrammer, nyttige tips og nyheter. Slett automatisk eller flytt til en annen mappe, filer eldre x -dag [Linux / SSH -kommandoer]

2 Tanker om “Slett automatisk eller flytt til en annen mappe, filer eldre x -dag [Linux / SSH -kommandoer]”

  1. perche quel comando mi cancella anche la cartella stessa? Vorrei cancellasse solo il contenuto! c’e una soluzione? grazie

    Svar
    • Capisco che hai diversi file nelle cartelle e vuoi solo spostare i file. Le cartelle rimangono intatte. Corretto? (GTrs).

      Svar
Legg igjen en kommentar