I want to use nc
as a simple TCP/IP server. So far I run it using:
$ nc -k -l 3000 > temp.tmp
This works, but writes all the received data of all connections into one single file. But, I would like to have individual files.
Basically I get this if I skip the -k
switch, but then nc
shuts down as soon as the first connection is gone.
How can I keep nc
running, but use an individual file for each incoming request? (Or, if this is not possible, is there an alternative *nix tool that is able to do this?)
Please note that I do not want to restart nc
, but I want it all with a single running instance.
PS: I know that SO doesn't allow questions on finding tools, but for me this is only the fallback in case nc
isn't able to do that by itself. So, sorry for the part in parentheses…
I think Cronolog can help in this case
-p option you can determine the period option
Also the filewatcher utility "incron" can be used which will check logs to one file & can split to some other files
Omit the
-k
and run it in a loop:On the receiver:
On the sender: