diff --git a/temp-cleanup/README.md b/temp-cleanup/README.md index b46b88c..f2dedf3 100644 --- a/temp-cleanup/README.md +++ b/temp-cleanup/README.md @@ -2,25 +2,31 @@ Dieses Repository enthält ein automatisiertes Cleanup-System für temporäre Dateien im Nextcloud-synchronisierten Dokumente-Ordner. +Es entfernt automatisch Dateien und leere Ordner nach 30 Tagen und sorgt so für eine saubere, schlanke Synchronisationsstruktur. + --- # 📁 Projektstruktur + +``` workstation-config/ └── temp-cleanup/ -├── cleanup_temp.sh -├── cleanup_temp.log -└── systemd/ -└── cleanup-temp.service + ├── cleanup_temp.sh + ├── cleanup_temp.log + └── systemd/ + └── cleanup-temp.service +``` --- # ⚙️ Zweck -Das Script löscht automatisch Dateien und leere Ordner im definierten `temp`-Verzeichnis nach 30 Tagen. +Das Script bereinigt automatisch das definierte `temp`-Verzeichnis. Ziel: - Verhindern von Datenmüll in synchronisierten Nextcloud-Ordnern -- Automatische Aufräumprozesse auf Workstations +- Automatisches Entfernen alter temporärer Dateien +- Aufräumen leerer Verzeichnisse --- @@ -28,28 +34,94 @@ Ziel: Der Service wird über **systemd (User oder System Service)** ausgeführt. -## 📍 Typischer Pfad (Installation auf Laptop) +## 📍 Installationspfade (Laptop) -```bash +### Script /home/kai/workstation-config/temp-cleanup/cleanup_temp.sh +### Service Datei (im Repo) /home/kai/workstation-config/temp-cleanup/systemd/cleanup-temp.service -muss kopiert werden nach + +### Zielort für systemd (User Service) ~/.config/systemd/user/cleanup-temp.service -🕒 Ausführungszeitpunkt +👉 Die Service-Datei muss bei Änderungen manuell kopiert werden. + +--- + +# 🔄 Service Installation / Reload + +Nach Änderungen der Service-Datei: + +cp ~/workstation-config/temp-cleanup/systemd/cleanup-temp.service ~/.config/systemd/user/ +systemctl --user daemon-reload +systemctl --user restart cleanup-temp.service + +--- + +# 🕒 Ausführungszeitpunkt Der Service wird ausgeführt über systemd Trigger, z. B.: -beim Login (User Service) -oder beim Systemstart (System Service) -optional manuell über systemctl start +- beim Login (User Service) +- beim Systemstart (optional System Service) +- manuell über systemctl start +--- -📜 Logfile +# 📜 Logfile Alle Aktionen werden protokolliert in: /home/kai/cleanup_temp.log +Enthält: +- gelöschte Dateien +- gelöschte Ordner +- Zeitstempel +- Fehlerausgaben (falls vorhanden) +--- + +# 🧪 Manueller Test + +## Script direkt ausführen +~/workstation-config/temp-cleanup/cleanup_temp.sh + +## Testdateien erstellen (älter als 30 Tage simulieren) +mkdir -p ~/Dokumente/temp +touch -d "40 days ago" ~/Dokumente/temp/test_old_file.txt + +## Testlauf starten +~/workstation-config/temp-cleanup/cleanup_temp.sh + +## Ergebnis prüfen +ls -la ~/Dokumente/temp +cat ~/cleanup_temp.log + +## Leere Ordner testen +mkdir -p ~/Dokumente/temp/old_folder +~/workstation-config/temp-cleanup/cleanup_temp.sh + +--- + +# 🧠 Designprinzip + +- Script ist portabel und läuft auf allen Workstations identisch +- Service wird bewusst nicht automatisch installiert +- Änderungen an Service-Dateien müssen manuell synchronisiert werden +- Logs bleiben lokal und werden nicht versioniert + +--- + +# 🔄 Versionierung + +git add . +git commit -m "Update cleanup system" +git push origin main + +--- + +# 🧩 Zielbild + +git clone \ No newline at end of file