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"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Cleanup temp folder
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/home/kai/cleanup_temp.sh
|
||||||
Reference in New Issue
Block a user