Add temp cleanup script and systemd service

This commit is contained in:
kai
2026-04-24 12:10:00 +02:00
parent 029df935e7
commit 585308c348
2 changed files with 31 additions and 0 deletions
+25
View File
@@ -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"
@@ -0,0 +1,6 @@
[Unit]
Description=Cleanup temp folder
[Service]
Type=oneshot
ExecStart=/home/kai/cleanup_temp.sh