clearautoscan.sh hinzugefügt
This commit is contained in:
1 parent
6ae9f69b4a
commit
f0a408a180
1 file changed
+28
@@ -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
|
||||||
Reference in new issue
Block a user