Sign up ×  I'm trying to leave netcat running and close the ssh
session (even stop the ssh daemon). But it then exits before all
of the data is written. I'm testing in a non-ssh (local)
console:  nohup nc -l -p 4000  | dd of=/home/myname/test.txt
2>/run/user/myname/stderr  1>/run/user/myname/stdout &  To test
it, I close the console and in another console I dump a file:
dd if=/var/log/Xorg.0.log  |  nc localhost 4000  Nothing gets
written in /home/myname/test.txt. But if I remove the nohup
command, test.txt contains all data dumped. How to get netcat
working and detached from the console ?  share|improve this
question  3 Answers 3  Try adding an extra '-d' option to netcat
(so it doesn't try to read from stdin). Using that and extending
the separate shell solution worked for me even after closing the
console and copying over a MB of data:  nohup sh -c 'nc -d -l
4000 | dd of=/home/user/dir/test.txt
1>/home/user/dir/stdout' & share|improve this answer up vote 1
down vote accepted  OK, I dug it down: nohup