Ich habe viele Beispiele für das Löschen von n Tagen alten Dateien in Linux gesehen, aber keiner von ihnen funktioniert für mich. Im Folgenden sind einige Befehle, die ichSo löschen Sie 1 Tag alte Dateien in Linux
verwendet[[email protected] dmp]# find . -mtime +1 -exec rm -Rf -- {} \;
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 11 21:01 GSW-11-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 12 02:30 GSW-12-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 13 02:30 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 11 21:01 MI-11-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 12 02:31 MI-12-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 02:30 MI-13-07-2016.dmp
[[email protected] dmp]# find . -name "*.dmp*" -ctime +1 -exec rm {} \;
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 11 21:01 GSW-11-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 12 02:30 GSW-12-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 13 02:30 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 11 21:01 MI-11-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 12 02:31 MI-12-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 02:30 MI-13-07-2016.dmp
[[email protected] dmp]# echo find . * -type f -mtime +1 -exec rm {} \;
find . GSW-11-07-2016.dmp GSW-12-07-2016.dmp GSW-13-07-2016.dmp MI-11-07-2016.dmp MI-12-07-2016.dmp MI-13-07-2016.dmp -type f -mtime +1 -exec rm {} ;
[[email protected] dmp]# find . * -type f -mtime +1 -exec rm {} \;
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 11 21:01 GSW-11-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 12 02:30 GSW-12-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 13 02:30 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 11 21:01 MI-11-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 12 02:31 MI-12-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 02:30 MI-13-07-2016.dmp
[[email protected] dmp]# find . * -mtime +1 -exec rm {} \;
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 11 21:01 GSW-11-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 12 02:30 GSW-12-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 13 02:30 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 11 21:01 MI-11-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 12 02:31 MI-12-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 02:30 MI-13-07-2016.dmp
[[email protected] dmp]# find . * -type f -mtime +1 -exec rm {} \;
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 11 21:01 GSW-11-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 12 02:30 GSW-12-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 13 02:30 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 11 21:01 MI-11-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 12 02:31 MI-12-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 02:30 MI-13-07-2016.dmp
[[email protected] dmp]# find . * -mtime +1 -exec rm -Rf -- {} \;
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 11 21:01 GSW-11-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 12 02:30 GSW-12-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 13 02:30 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 11 21:01 MI-11-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 12 02:31 MI-12-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 02:30 MI-13-07-2016.dmp
[[email protected] dmp]# find . -type f -mtime +1 -name '*.dmp' -execdir rm -- {} \;
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 11 21:01 GSW-11-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 12 02:30 GSW-12-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 13 02:30 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 11 21:01 MI-11-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 12 02:31 MI-12-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 02:30 MI-13-07-2016.dmp
[[email protected] dmp]# find . -type f -ctime +1 -name '*.dmp' -execdir rm -- {} \;
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 11 21:01 GSW-11-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 12 02:30 GSW-12-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 13 02:30 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 11 21:01 MI-11-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 12 02:31 MI-12-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 02:30 MI-13-07-2016.dmp
[[email protected] dmp]# find . -type f -mtime +1 -name '*.dmp' -print0 | xargs -r0 rm --
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 11 21:01 GSW-11-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 12 02:30 GSW-12-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 13 02:30 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 11 21:01 MI-11-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 12 02:31 MI-12-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 02:30 MI-13-07-2016.dmp
2) Ich versuche, auch alte Dateien vom FTP-Remote-Server zu löschen und habe meine Frage hier https://stackoverflow.com/questions/38309645/linux-script-to-delete-ndays-old-ftp-files
UPDATE:
ich die Antwort versucht, aber noch kein Glück
[[email protected] dmp]# find . -type f -mtime +1 -exec rm -rf {} \;
[[email protected] dmp]# ll
total 3259164
-rw-r----- 1 oracle dba 12754944 Jul 13 17:16 GSW-13-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 14 02:30 GSW-14-07-2016.dmp
-rw-r----- 1 oracle dba 12754944 Jul 15 02:30 GSW-15-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 13 17:16 MI-13-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 14 02:30 MI-14-07-2016.dmp
-rw-r----- 1 oracle dba 1099702272 Jul 15 02:30 MI-15-07-2016.dmp
[[email protected] dmp]#
Bitte beraten, wie kann ich es beheben. Dank im Voraus
Möchten Sie die Dateien aufgelistet ist, wenn Sie 'statt' rm' ls' angeben? – choroba
Abstimmung für 'ls' Idee statt' rm' – LifeSaver
* Abstimmung für 'ls' Idee statt' rm' *, cool, also welches Ergebnis haben Sie bekommen? War es erwartet (Sie haben die Namen der Dateien gesehen, die Sie löschen möchten)? Ich habe es gerade versucht. -mtime +1 -exec rm -Rf - {} \; 'und es hat gut für mich funktioniert. – lurker