Is there any way to send the Log Files via eMail before flushing every 24 hours?
Have You tried to create a cron-job?
Sorry, but my Linux Skills are awesome (like my english).
How can i do this?
Not overly familiar myself, but a little Googling has turned up the following:
Would the development team consider setting up log rotation for the pihole log, instead of flushing it? This would make mailing the results of the previous day a lot more easy.
It's certainly a possibility. I think this is probably something we could have as a setting, as some people may not even want to keep days and days worth of logs
sending the log with SSMTP:
- configure SSMTP as explained in chapter 4.8 in this manual
- Install sharutils (contains uuencode):
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install sharutils
- create the script to send the log as attachment:
sudo nano sendlog.sh
- enter the command:
echo -e "to: <your_account_name>@gmail.com\nsubject: pihole log\n"| (cat - && uuencode /var/log/pihole.log pihole.log) | /usr/sbin/ssmtp <your_account_name>@gmail.com
everything on one line, replace <your_account_name> with the correct mail address (twice), you will basically send a mail to yourself. - make the script executable:
sudo chmod 755 ./sendlog.sh
- test the script:
./sendlog.sh
if you received a mail, containing the attachment, you probably need to open it with an editor that understands unix formatted text files, I use notepad++ - to automate this, on a daily base, create a cron file
sudo nano /etc/cron.d/sendlog
- enter the job
56 23 * * * root PATH="$PATH:/home/pi" sendlog.sh
this will mail the log at 23h56, you need to allow sufficient time to read and send the log, before the pihole script flushes it at 00h00
if the developers would implement logrotation (or you are implementing it yourself), you would be able to run the cron job the next day e.g.
00 05 * * * root PATH="$PATH:/home/pi" sendlog.sh
you would need to change the filename from pihole.log to pihole.log.1 e.g.
echo -e "to: <your_account_name>@gmail.com\nsubject: pihole log\n"| (cat - && uuencode /var/log/pihole.log.1 pihole.log.1) | /usr/sbin/ssmtp <your_account_name>@gmail.com
hope this helps...
Possibly fixed with the new logrotate feature.
@peneu76: Long term stats in v3.2 won't specifically address your request, but may negate the need for it?