Last active
January 18, 2024 20:52
-
-
Save pancudaniel7/eaafcabc20374dd3f353273bda7e81ff to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/bash | |
# Logrotate Configuration | |
echo "Setting up Logrotate configuration for your application..." | |
sudo cat <<EOF > /etc/log_size_check.conf | |
/var/log/syslog { | |
su root root | |
size 100M | |
copytruncate | |
rotate 30 | |
compress | |
missingok | |
notifempty | |
delaycompress | |
postrotate | |
/usr/lib/rsyslog/rsyslog-rotate | |
endscript | |
} | |
EOF | |
echo "Creating Systemd service file for Logrotate..." | |
sudo cat <<EOF > /etc/systemd/system/log_size_check.service | |
[Unit] | |
Description=Rotate log files if size exceeded | |
[Service] | |
ExecStart=/usr/sbin/logrotate /etc/log_size_check.conf | |
EOF | |
# Systemd Timer File | |
echo "Creating Systemd timer file for Logrotate..." | |
sudo cat <<EOF > /etc/systemd/system/log_size_check.timer | |
[Unit] | |
Description=Run logrotate every 10 minutes | |
[Timer] | |
OnCalendar=*:0/10 | |
Persistent=true | |
[Install] | |
WantedBy=timers.target | |
EOF | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment