I'm trying to force GNU screen to create a "virtual" terminal, without attaching to it, execute script inside and NOT terminate session once script ends.
I tried many combinations, including:
screen -dmS udplistener /share/Sys/autorun/start_udp_listeners.sh
screen -S udplistener -X /share/Sys/autorun/start_udp_listeners.sh
and none of them worked. I either get session without executed script, script executes, but session is terminated once it finishes or I'm getting "No screen session found" error.
What I'm basically trying to do is to run UDP listener, written in PHP and make it work in infinte loop (don't break listening). Yes -- I could run PHP script with
& at the end, forcing PHP CLI to run as daemon. The problem is, that I'm using a piece of junk called server (QNAP -- never, ever buy this junk!) which does seems to be ignoring this. As soon as I logoff SSH session, scripts stops.
screen seems to be the only option. But I can't understand, why it terminates session once executed command or script ends?
EDIT: I've also tried example found in the Internet:
screen -dmS name screen -S name -p windowname -X stuff 'mc '
No lack! After attaching to it (
screen -R name) I see that Midnight Commander HASN'T been executed. Though example author said, it will be.