arch logs

This commit is contained in:
2024-08-24 06:50:37 +03:00
parent d4146682a8
commit 1aee085398
3 changed files with 28 additions and 2 deletions

21
archive_logs.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Get the current date and time in YYYY-MM-DD-HHMMSS format
current_datetime=$(date +"%Y-%m-%d-%H%M%S")
# Archive name
archive_name="logs-$current_datetime.tar.gz"
# Create the logs directory if it doesn't exist
mkdir -p logs
# Create a tar.gz archive of all .log files
tar -czf "$archive_name" *.log
# Move the archive to the logs directory
mv "$archive_name" logs/
# Remove the original .log files
rm -f *.log
echo "Logs archived and moved to logs/ directory. Original log files removed."