2

Problem:

I want to pipe the output of docker logs -f ( for all containers ) into another command and keep it running on the remote server. I already found Run a nohup command over SSH, then disconnect but I had no success adopting the solution to this use case.

What have I tried so far:

ssh server << EOF
for cont in `docker ps -q`; do
        docker logs -f $cont 2>&1 | bunyan | /var/opt/go-logsink/go-logsink connect 2>&1 &
done
EOF

nohup version: nohup "docker logs -f $cont 2>&1 | bunyan | /var/opt/go-logsink/go-logsink connect"

Running that loop within a screen session works, but I want to automate the call after a deployment and that does not work. Also I tried calling nohup "<command>" within the loop and I see it creating the process, upon disconnection of ssh the processes get killed.

Question:

How to run that loop so it creates processes that stay alive after ssh session close.

4
  • How did you use nohup here?
    – muru
    Feb 7, 2017 at 6:39
  • 1
    And how did you use screen?
    – Melebius
    Feb 7, 2017 at 6:40
  • @Melebius I logged into the server interactivly. I mentioned my current workaround.
    – Sascha
    Feb 7, 2017 at 8:09
  • @muru updated question
    – Sascha
    Feb 7, 2017 at 8:13

1 Answer 1

1

Screen or tmux may be what you're looking for, preserving sessions alive independently from SSH.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .