From 3fd2ffd46692ba1fd2fb50f1b8523ef69a3ffb9a Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 12 Jan 2017 20:39:25 +0100 Subject: [PATCH 1/4] Add logrotate for pihole.log --- advanced/Scripts/piholeLogFlush.sh | 7 ++++++- advanced/logrotate | 9 +++++++++ advanced/pihole.cron | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 advanced/logrotate diff --git a/advanced/Scripts/piholeLogFlush.sh b/advanced/Scripts/piholeLogFlush.sh index 8b16e3d5..5f16aaee 100755 --- a/advanced/Scripts/piholeLogFlush.sh +++ b/advanced/Scripts/piholeLogFlush.sh @@ -11,5 +11,10 @@ # (at your option) any later version. echo -n "::: Flushing /var/log/pihole.log ..." -echo " " > /var/log/pihole.log +# Test if logrotate is available on this system +if command -v /usr/sbin/logrotate &> /dev/null; then + /usr/sbin/logrotate --force /etc/.pihole/logrotate +else + echo " " > /var/log/pihole.log +fi echo "... done!" diff --git a/advanced/logrotate b/advanced/logrotate new file mode 100644 index 00000000..e9be016d --- /dev/null +++ b/advanced/logrotate @@ -0,0 +1,9 @@ +/var/log/pihole.log { + daily + copytruncate + rotate 5 + compress + delaycompress + notifempty + nomail +} diff --git a/advanced/pihole.cron b/advanced/pihole.cron index 8311acfb..d1e20d8b 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -23,4 +23,7 @@ # Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control # Stats will be viewable in the Web interface thanks to the cron job above +# The flush script will use logrotate if available 00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush + +@reboot /usr/sbin/logrotate --force /etc/.pihole/logrotate From 6b6fbc4709cd035066113bbcc331bcea249c9009 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 12 Jan 2017 20:41:25 +0100 Subject: [PATCH 2/4] Remove --force on @reboot --- advanced/pihole.cron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/pihole.cron b/advanced/pihole.cron index d1e20d8b..1c3f9581 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -26,4 +26,4 @@ # The flush script will use logrotate if available 00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush -@reboot /usr/sbin/logrotate --force /etc/.pihole/logrotate +@reboot /usr/sbin/logrotate /etc/.pihole/logrotate From 3a8a936575d959ce8faae95661d17fd981c0c344 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 12 Jan 2017 21:01:52 +0100 Subject: [PATCH 3/4] Corrected path --- advanced/Scripts/piholeLogFlush.sh | 2 +- advanced/pihole.cron | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/piholeLogFlush.sh b/advanced/Scripts/piholeLogFlush.sh index 5f16aaee..64833b64 100755 --- a/advanced/Scripts/piholeLogFlush.sh +++ b/advanced/Scripts/piholeLogFlush.sh @@ -13,7 +13,7 @@ echo -n "::: Flushing /var/log/pihole.log ..." # Test if logrotate is available on this system if command -v /usr/sbin/logrotate &> /dev/null; then - /usr/sbin/logrotate --force /etc/.pihole/logrotate + /usr/sbin/logrotate --force /etc/.pihole/advanced/logrotate else echo " " > /var/log/pihole.log fi diff --git a/advanced/pihole.cron b/advanced/pihole.cron index 1c3f9581..8a865540 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -26,4 +26,4 @@ # The flush script will use logrotate if available 00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush -@reboot /usr/sbin/logrotate /etc/.pihole/logrotate +@reboot /usr/sbin/logrotate /etc/.pihole/advanced/logrotate From bcb8a52418e3ace78111eed7a9440c1067133a30 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 13 Jan 2017 11:57:07 +0100 Subject: [PATCH 4/4] Added user to cron file --- advanced/pihole.cron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/pihole.cron b/advanced/pihole.cron index 8a865540..e8bc7ba9 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -26,4 +26,4 @@ # The flush script will use logrotate if available 00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush -@reboot /usr/sbin/logrotate /etc/.pihole/advanced/logrotate +@reboot root /usr/sbin/logrotate /etc/.pihole/advanced/logrotate