From f0a408a180829106d6989e0ae0a12803fe3cd7aa Mon Sep 17 00:00:00 2001 From: Daniel <2+daniel@noreply.localhost> Date: Thu, 10 Sep 2026 04:33:15 +0000 Subject: [PATCH] =?UTF-8?q?clearautoscan.sh=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clearautoscan.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 clearautoscan.sh diff --git a/clearautoscan.sh b/clearautoscan.sh new file mode 100644 index 0000000..8bd0a5a --- /dev/null +++ b/clearautoscan.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +#written by Daniel Wenzlik 2025 - https://danielwenzlik.com +#Script under the GNU AGPLv3 license. + +# Variables +directory="/var/log/clamav/autoscan/"; +current_month=$(date +'%Y-%m'); + +# Check directory for existing files +for file in "$directory"/clamav-*.log; do + # Check if the file is actually there + echo "Check if the file is actually there" + if [[ -f "$file" ]]; then + # Extracting the date + echo "Extracting the date" + file_date=$(basename "$file" | cut -d'-' -f2-3) + + # Check if the date is equal to the current month & year + echo "Check if the date is equal to the current month & year" + if [[ "$file_date" != "$current_month" ]]; then + # Delete the file + echo "Delete the file" + rm "$file" + echo "Gelöscht: $file" + fi + fi +done \ No newline at end of file