Created
March 4, 2025 16:35
-
-
Save carlHandy/71b851cacd76deef58cb6b85ed9b7ffb to your computer and use it in GitHub Desktop.
Logwatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Logwatch setup script | |
LOGWATCH_CONF="/etc/logwatch/conf/logwatch.conf" | |
LOGWATCH_SCRIPT="/etc/cron.daily/logwatch" | |
# Update and install Logwatch | |
echo "Updating package list and installing Logwatch..." | |
sudo apt update -y && sudo apt install logwatch -y | |
# Create Logwatch config directory if it doesn't exist | |
echo "Configuring Logwatch..." | |
sudo mkdir -p /etc/logwatch/conf | |
# Set email recipient and detail level | |
echo "Setting Logwatch configuration..." | |
sudo tee "$LOGWATCH_CONF" > /dev/null <<EOL | |
Output = mail | |
Format = text | |
MailTo = [email protected] | |
Detail = High | |
EOL | |
# Create a cron job to run Logwatch daily | |
echo "Setting up daily cron job for Logwatch..." | |
sudo tee "$LOGWATCH_SCRIPT" > /dev/null <<'EOL' | |
#!/bin/bash | |
/usr/sbin/logwatch --output mail --mailto [email protected] --detail high | |
EOL | |
# Make the script executable | |
sudo chmod +x "$LOGWATCH_SCRIPT" | |
# Run Logwatch manually to verify | |
echo "Running Logwatch manually for verification..." | |
sudo /usr/sbin/logwatch --output mail --mailto [email protected] --detail high | |
echo "Logwatch setup complete! Daily reports will be sent to your email." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment