std*_*err 6 linux shell command-line gnu-screen
我想从脚本中启动屏幕内的python脚本.我试过这个
screen -dmS gateway_monitor;screen -r gateway_monitor -p 0 -X '/usr/bin/python /root/Gateway.py'
Run Code Online (Sandbox Code Playgroud)
但是如果我之后重新连接到屏幕上,它只是空的,看起来根本没有执行任何操作.任何线索为什么这是我或如何实现我想要的?
您可以使用:
screen -dm bash -c 'python your_script.py'
Run Code Online (Sandbox Code Playgroud)
如果您需要多个命令,请使用;:
screen -dm bash -c 'source ~/.bash_profile; python your_script.py'
Run Code Online (Sandbox Code Playgroud)
文档:
https://www.gnu.org/software/screen/manual/screen.html:
-d -m:以分离模式启动屏幕.这会创建一个新会话但不会附加到该会话.这对系统启动脚本很有用.
http://linux.about.com/library/cmd/blcmdl1_sh.htm:
-c string:如果存在-c选项,则从字符串中读取命令.如果字符串后面有参数,则将它们分配给位置参数,从$ 0开始.