문제

I have recently come across this post which says that it is possible to force a script to run in screen with a shebang. My question is, how does one do this if I want to reconnect to an existing screen session (and thus force the script to run under screen).

So, on my server, when I do screen -list, I see:

There is a screen on:
    22566.myscreen  (10/26/13 23:47:09) (Detached)
1 Socket in /var/run/screen/S-admin.

Now, I have the following bash script, and I would like the bash script to be run with the above screen session. At the moment, I have something like this:

#!/usr/bin/screen -r "myscreen" /bin/bash
# /home/foo/jobscripts/script.sh
#

echo $STY
git status
touch /home/foo/jobscripts/testsuccess.txt
exit 0

... but this obviously does not work and tells me Error: Unknown option r "myscreen" /bin/bash Wondering if there was a way to specify in shebang to reattach to my above screen.

도움이 되었습니까?

해결책

For Linux, I think we should just use something like pid.sessionname.

For other Unix-like OS, it may also indicate the TTY like this pid.tty.sessionname.

To be sure, consult your manpage of screen : man screen

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top