I want to SSH into a machine, start a process, write the stdErr and stdOut of the process into two seperate files while reading the stdOut/stdErr in the console. As soon as some specific lines were written in the stdOut/stdErr (of the console), I want to disconnect the SSH session, while keeping the process running in the background.
At the moment I'm using nohup to start the process in the background, log stdout and stderr to a file and return the pid of the started process. What is missing is the part where I can still get the stdOut/stdErr from the console, till I decide that I want to disconnect the SSH session, while letting the process run in the background.
Here is a simple example with a ping script
#!bin/bash nohup bash ~/ping.sh > foo.out 2> foo.err & echo $!
#!bin/bash /bin/ping -c 8 superuser.com