arch logs
This commit is contained in:
21
archive_logs.sh
Executable file
21
archive_logs.sh
Executable 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."
|
||||
Reference in New Issue
Block a user