I try to delete backup files on my Synology NAS older than 30 days. The files are in a directory which is created during download of the backup files from my webserver.
After download, I want to check -mtime and then delete the older files.
Here comes the script:
#!/bin/sh
## Datum auslesen
datum=`date +%Y-%m-%d_%H-%M`
## Mit wget die Datei AutoBackupDB-1.zip laden und in einem Ordner mit Datum uns Uhrzeit speichern
wget -m -P /volume1/Austauschordner/backup_xyz/$datum/ ftp://backup:backup@domain.tdl/AutoBackupDB-1.zip
echo "Backup von xyz wurde erstellt! "
## finde alle Ordner in einem angegebenen Verzeichnis mit dem Suchnamen die älter als die angegebenen Tage sind und lösche diese
find /volume1/Austauschordner/ -type d -name 'backup_*' -ctime +30 -delete
If I run this script it tells me that the "directory isn't empty" and nothing will be deleted.
Is there an easy way or an option to delete everything in the directory?
__pycache__
, plus this one have better answers and has more votes. – kenorb Jan 27 '24 at 23:42__pycache__
? You could replace that with any directory name in the commands there and it would work just as well. Voting to leave closed. – muru Jan 29 '24 at 04:49