There is a service that periodically sends packets to the server on a specific port. I want to put netcat on it to all incoming packets to save in the specified file in the background.
If you run
nc-k -lp 8080 >> data.txt &
It takes a single packet and exits.
If you run this:
while true; do nc-k -lp 8080 >> data.txt; done &
The process accepts and records a single package, displays in the console something like:
+ Stopped while true; do
nc-k -lp 8080 >> data.txt;
continues to hang in processes, but in the file nothing write.
How to run netcat to hang in the background and continued to write packets to a file?
The system is Debian GNU/Linux 9
P. S. While I decided it's not running in the background, and screen. But I would like a more elegant solution.