2 added 389 characters in body
source | link

I find the -d -m option works but not with the quotes. I'd need to do:

ssh myuser@hostname screen -d -m python somepath.py -s 'potato'

I don't know why the accepted answer has quotes around the command as they aren't called for in the GNU documentation and they break it on my system (Centos 7).

For what it's worth: I noticed the screen doesn't stay alive when run via ssh under Jenkins. It's alive while the parent ssh connection and sh script are running, but dies when the parent closes, so there may be cases where screen can't solve the problem.

I even tried using this trick:

https://stackoverflow.com/questions/39471261/must-be-connected-to-a-terminal-error-with-screen-x-command-on-a-linux-contai

adding

script /dev/null

before the screen call, but it didn't fix the problem. I don't know what magic jenkins is doing to make everything die, but it's effective.

It might be killed after the fact by the jenkins process killer which could be disabled by adding:

export BUILD_ID=dontKillMe

https://serverfault.com/questions/502593/starting-a-forever-process-in-a-jenkins-build-step

In my case I had luck keeping a long running process (ssh tunnel) going by adding dontKillMe, although I moved away from using screen as it was unnecessary.

I find the -d -m option works but not with the quotes. I'd need to do:

ssh myuser@hostname screen -d -m python somepath.py -s 'potato'

I don't know why the accepted answer has quotes around the command as they aren't called for in the GNU documentation and they break it on my system (Centos 7).

For what it's worth: I noticed the screen doesn't stay alive when run via ssh under Jenkins. It's alive while the parent ssh connection and sh script are running, but dies when the parent closes, so there may be cases where screen can't solve the problem.

I even tried using this trick:

https://stackoverflow.com/questions/39471261/must-be-connected-to-a-terminal-error-with-screen-x-command-on-a-linux-contai

adding

script /dev/null

before the screen call, but it didn't fix the problem. I don't know what magic jenkins is doing to make everything die, but it's effective.

I find the -d -m option works but not with the quotes. I'd need to do:

ssh myuser@hostname screen -d -m python somepath.py -s 'potato'

I don't know why the accepted answer has quotes around the command as they aren't called for in the GNU documentation and they break it on my system (Centos 7).

For what it's worth: I noticed the screen doesn't stay alive when run via ssh under Jenkins. It's alive while the parent ssh connection and sh script are running, but dies when the parent closes, so there may be cases where screen can't solve the problem.

I even tried using this trick:

https://stackoverflow.com/questions/39471261/must-be-connected-to-a-terminal-error-with-screen-x-command-on-a-linux-contai

adding

script /dev/null

before the screen call, but it didn't fix the problem. I don't know what magic jenkins is doing to make everything die, but it's effective.

It might be killed after the fact by the jenkins process killer which could be disabled by adding:

export BUILD_ID=dontKillMe

https://serverfault.com/questions/502593/starting-a-forever-process-in-a-jenkins-build-step

In my case I had luck keeping a long running process (ssh tunnel) going by adding dontKillMe, although I moved away from using screen as it was unnecessary.

1
source | link

I find the -d -m option works but not with the quotes. I'd need to do:

ssh myuser@hostname screen -d -m python somepath.py -s 'potato'

I don't know why the accepted answer has quotes around the command as they aren't called for in the GNU documentation and they break it on my system (Centos 7).

For what it's worth: I noticed the screen doesn't stay alive when run via ssh under Jenkins. It's alive while the parent ssh connection and sh script are running, but dies when the parent closes, so there may be cases where screen can't solve the problem.

I even tried using this trick:

https://stackoverflow.com/questions/39471261/must-be-connected-to-a-terminal-error-with-screen-x-command-on-a-linux-contai

adding

script /dev/null

before the screen call, but it didn't fix the problem. I don't know what magic jenkins is doing to make everything die, but it's effective.