Log DNS-Query-file to network-share or ftp

Hello,

has anyone tried to move the log-files from the SD-card to a network-share (samba, ftp, ...) ?

Greets

Do you mean something like move entirely or move only the backup files that are created daily by logrotate?

Hy,

Would like to move entirely.

The location is currently hard-coded but you might be successful with using symlink. Let me try and report back when I have something for you.

I summarized my finding in an FAQ article:

@DL6ER
Logs does not get flush when moving the log.

I know, look at the introduction + steps 8-10.

I get:
-bash: /etc/cron.d/pihole-custom-flushing: Permission denied
in step 10... any suggestions?

Try:

echo "@reboot root /usr/sbin/logrotate /etc/pihole/logrotate-custom" | sudo tee -a /etc/cron.d/pihole-custom-flushing

Thanks.... I think it worked.... How do I control if it worked?

Is this correct?

sudo echo "0 0 * * * root /usr/sbin/logrotate --force /etc/pihole/logrotate-custom" | sudo tee -a /etc/cron.d/pihole-custom-flushing
echo "@reboot root /usr/sbin/logrotate /etc/pihole/logrotate-custom" | sudo tee -a /etc/cron.d/pihole-custom-flushing

I dont understand what you mean.
You got stuck because of a permissions error so I gave you the workaround command.
If you want to check if the command worked, just open involved file with a viewer like for example less and check if a line was added at the bottom starting with "@reboot ...":

less /etc/cron.d/pihole-custom-flushing

Sorry if I didn't explained my question,, but it seems to work now... many thanks.

Good to hear.
I understand now what you tried to convey before.
This is original from step 10:

sudo echo "0 0 * * * root /usr/sbin/logrotate --force /etc/pihole/logrotate-custom" > /etc/cron.d/pihole-custom-flushing
sudo echo "@reboot root /usr/sbin/logrotate /etc/pihole/logrotate-custom" >> /etc/cron.d/pihole-custom-flushing

This is your proposal:

sudo echo "0 0 * * * root /usr/sbin/logrotate --force /etc/pihole/logrotate-custom" | sudo tee -a /etc/cron.d/pihole-custom-flushing
echo "@reboot root /usr/sbin/logrotate /etc/pihole/logrotate-custom" | sudo tee -a /etc/cron.d/pihole-custom-flushing

But the first line of commands in step 10 is not appending ">>" to the file "/etc/cron.d/pihole-custom-flushing" ,
but instead is creating ">" the file so you can leave out the "-a" option for the "tee" command.
And you can leave out "sudo" at the beginning so the result would be:

echo "0 0 * * * root /usr/sbin/logrotate --force /etc/pihole/logrotate-custom" | sudo tee /etc/cron.d/pihole-custom-flushing
echo "@reboot root /usr/sbin/logrotate /etc/pihole/logrotate-custom" | sudo tee -a /etc/cron.d/pihole-custom-flushing

Validate using cat command:

$ cat /etc/cron.d/pihole-custom-flushing
0 0 * * * root /usr/sbin/logrotate --force /etc/pihole/logrotate-custom
@reboot root /usr/sbin/logrotate /etc/pihole/logrotate-custom

Please note (more as a general advise) the implications of what @deHakkelaar said:

sudo echo "something" > /somewhere/somefile

This does not work at all, since what you are doing here is calling echo with elevated permissions, but the problem is that the shell does output redirection, neither sudo nor echo, so this is being done as your regular user and hence won't work at all if you don't have write permissions for /somewhere/somefile ! Users often oversee this conceptual detail and wonder why it does not work for them. On the other hand, there is a vast majority of users that work as root on their daily business ... you should disallow using a computer altogether for this class of users, but that is a different story for a different day :slight_smile:

Please always use something like

echo "something" | sudo tee /somewhere/somefile

or even

echo "something" | sudo tee /somewhere/somefile > /dev/null

to avoid printing back to the terminal.

Go fix quickly in this post :smiley:

Oh, that wasn't my code, but you can truly blame me for copy-paste w/o thinking about it! Thanks :wink:

I dont know whats the worst,
me being root all the time,
or people blatently copying pasting bugs into all sorts of things :wink:

Making things worse, I even have a windows station logged in as Administrator all the time :smiley:

Seriously, the answer is clear: being root all the time is just nuts. No joke.
Take the time to read some of these answers to convince yourself.

No comments from me on Win at all...