Running script on screen

I want to run a python script inside the screen from a script. I tried this

screen -dmS gateway_monitor;screen -r gateway_monitor -p 0 -X '/usr/bin/python /root/Gateway.py'

but if I join the screen again, it is just empty and it looks like nothing was done at all. Any clues why this is or how I get what I want?

+5
source share
1 answer

You can use:

screen -dm bash -c 'python your_script.py'

If you need multiple commands, use ;:

screen -dm bash -c 'source ~/.bash_profile; python your_script.py'

Documentation:

https://www.gnu.org/software/screen/manual/screen.html :

-d -m: launch the screen in separate mode. This creates a new session, but does not bind to it. This is useful for system startup scripts.

http://linux.about.com/library/cmd/blcmdl1_sh.htm :

-c string: -c, . , , $0.

+3

All Articles