I have the task to start a detached
screen session (e.g. when the system reboots) and then to be able to connect to it and interrupt/kill the running process without the screen to terminate. Unfortunately when I attach to the
screen session and stop the running command, the entire
screen session terminates with:
[screen is terminating]
I am using the following command to start the detached
screen -dm -S screen_name /bin/bash -c 'cd ~/mydir; npm start'
then I attach to the
screen session using:
screen -r session_name
and if I
bash command will exit and the screen is terminating.
What I want is to achieve a similar behaviour when attaching to the screen as if I would have started the
npm inside the
screen session manually:
screen -S session_name
and then inside the
cd ~/mydir npm start
then I can
npm command without the
screen session being terminated.