linux - 在 screen 中启动脚本

标签 linux shell command-line gnu-screen

我想从一个脚本在 screen 内启动一个 python 脚本。我试过了

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

但如果我之后重新连接到 screen ,它只是空的,看起来像 什么都没有执行。任何线索为什么会这样或我如何得到 实现了我想要的?

最佳答案

您可以使用:

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

如果你需要多个命令,使用;:

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

文档:

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

-d -m: Start screen in detached mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.

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

-c string: If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.

关于linux - 在 screen 中启动脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12631479/

相关文章:

即使添加到 PATH 后,Windows CMD 也无法识别 python

javascript - NodeJS 可以在网络上使用而不是在命令行上使用吗

javascript - 在哪里输入我的 Node 命令以及为什么?

linux - * NIX GUI如何工作?

Linux:在端口 0 上绑定(bind)时会发生什么

linux - TIFF 打开 : Too many open files

linux - 如何将应用模板的值存储在变量中?

linux - 写一个shell脚本,在连接丢失时保持重新连接SSH for proxy

sqlite - 如何使用elisp创建一个sqlite特定的shell?

linux - Linux中的每个Shell命令是否都在后端调用系统调用