Add temp cleanup script and systemd service
This commit is contained in:
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
TARGET="/home/kai/Dokumente/temp"
|
||||
LOG="/home/kai/cleanup_temp.log"
|
||||
|
||||
# kleine Verzögerung damit Nextcloud Zeit hat
|
||||
sleep 60
|
||||
|
||||
echo "===== Cleanup Run: $(date) =====" >> "$LOG"
|
||||
|
||||
if [ -d "$TARGET" ]; then
|
||||
echo "Scanning: $TARGET" >> "$LOG"
|
||||
|
||||
# Dateien älter als 30 Tage löschen
|
||||
find "$TARGET" -type f -mtime +30 -print -delete >> "$LOG" 2>&1
|
||||
|
||||
# Leere Ordner löschen
|
||||
find "$TARGET" -type d -empty -print -delete >> "$LOG" 2>&1
|
||||
|
||||
echo "Cleanup finished" >> "$LOG"
|
||||
else
|
||||
echo "Directory not found: $TARGET" >> "$LOG"
|
||||
fi
|
||||
|
||||
echo "" >> "$LOG"
|
||||
Reference in New Issue
Block a user