I have an embedded Busybox system with ash shell. On this system is a service with logging output. I want to have this logfile on another computer. This service creates the log file, but I can specify the filename via parameter. The memory is very fast filled up. What could be the easiest way to transfer this file on the fly to another linux machine? I cant install much additional software. I want to run the service for hours, without starting&stopping the service when the space is used.
I thought something like starting the service and writing the log into the file, but transferring the data with netcat to another machine. Where a second netcat instance writes it to hd. If I specify - as filename (for writing the log to stdout), the service only creates a file called --01.log in the current directory. I only need a hint that directs me into the correct direction.
Your problem is not unique and it has been solved long time ago. Configure busybox syslogd to send message logs to a remote logging service (a remote server).
If you want to rediscover the wheel on you own. Setup a log rotation policy in busybox and then send the rotated archive to another server using rsync or scp.
Its not this kind of log. Its a plain file created by a program. There is nothing in the syslog.
The system has only 2MB free flash drive and 60MB ram. mounting nfs is not supported.
If you have the logger program installed you could write a small script reading the log file, creating syslog messages out of it and then truncate the log file accordingly. If the program is creating the logfile by redirectio you could even use a pipe and forego the logfile completely:
/my/app > /some/log # turn that into:
/my/app | /some/script_with_logger
logger is part of many Linux distributions and is used to create syslog messages from the commandline.