pi-hole/advanced/Scripts/piholeLogFlush.sh

25 lines
836 B
Bash
Raw Normal View History

2015-12-06 13:55:50 +00:00
#!/usr/bin/env bash
2016-01-30 20:12:40 +00:00
# Pi-hole: A black hole for Internet advertisements
2017-02-22 17:55:20 +00:00
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
# Network-wide ad blocking via your own hardware.
#
# Flushes Pi-hole's log file
2015-12-06 13:55:50 +00:00
#
2017-02-22 17:55:20 +00:00
# This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license.
2016-04-03 17:27:18 +00:00
echo -n "::: Flushing /var/log/pihole.log ..."
2017-01-12 19:39:25 +00:00
# Test if logrotate is available on this system
if command -v /usr/sbin/logrotate >/dev/null; then
# Flush twice to move all data out of sight of FTL
/usr/sbin/logrotate --force /etc/pihole/logrotate; sleep 3
/usr/sbin/logrotate --force /etc/pihole/logrotate
2017-01-12 19:39:25 +00:00
else
# Flush both pihole.log and pihole.log.1 (if existing)
2017-01-12 19:39:25 +00:00
echo " " > /var/log/pihole.log
if [ -f /var/log/pihole.log.1 ]; then
echo " " > /var/log/pihole.log.1
fi
2017-01-12 19:39:25 +00:00
fi
2016-04-03 17:27:18 +00:00
echo "... done!"