我想从一个脚本在 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/