2

I run a script as a daemon which gets started and stopped via /etc/init.d on a Raspberry Pi. For a number of reasons - including limited local file storage - I'd like to direct stdout and stderr from the script to a remote server for logging and post-mortem analysis.

At the risk of asking an overly general question: what's the preferred technique for remote logging?

Should I create a second process on the Raspberry Pi that does tail -f on whatever daemon creates? Would syslog-ng be useful here? Should I expect to write custom code on the remote server, or are there packages already set up to do this sort of stuff?

Etc. I would be surprised if this wasn't already completely solved; I simply don't know what phrases and package names to Google.

  • Preliminary comment: It appears that a preferred approach is to call the system's generic syslog facility (e.g in Python, syslog.syslog(message), and configure syslog to push its contents to a remote logger. But that's only about 20% of the answer. – fearless_fool Sep 4 '14 at 3:39
0

You can write log files to a remote host in multiple ways. As a comment points out, you could perhaps configure your syslog facility to do this for you.

Another way would be to simply mount a remote filesystem on the raspberry over nfs, ssh, samba, and write directly to it.

Here's how it can be done using nfs:

On the linux server: define your resource in /etc/exports:

/media/mydisk      10.10.30.0/24(rw,no_root_squash,subtree_check,insecure)

Install and start nfs

On the raspberry, in /etc/fstab:

server-name:/media/mydisk   /mnt/mydisk  nfs  auto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,soft,intr,noatime 0 0

Now you should be able to "mount /media/mydisk" on the rasberry and have it available upon boot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.