I want to tail -f
a local file, for example app1.log, and send its output to a file on a remote server.
tail -f app1.log >> <remote server>:/home/remote.log
Is this doable?
I want to tail -f
a local file, for example app1.log, and send its output to a file on a remote server.
tail -f app1.log >> <remote server>:/home/remote.log
Is this doable?
You can pipe STDOUT
through SSH to a remote host:
tail -f - app1.log | ssh user@remote.host "cat > app1.log"
If you don't care too much about encryption end to end, you can spin up netcat
on the receiving host and pipe tail
to the remote listening netcat or socat, but that would be evil, so I won't provide copy-pasta. :D
You can use rsyslog if you have rsyslog server on the other side. The problem is, it is very difficult to track what was your last message sent. It all depends on the way you implement it how important your logs are.