9

スクリプトから画面内でpythonスクリプトを起動したい。私はこれを試しました

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

しかし、後で画面に再度接続すると、何も実行されていないように見えます。これがなぜなのか、または私が望むものをどのように達成するのか、手がかりはありますか?

4

1 に答える 1

11

You can use:

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

If you need several 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: 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.

于 2016-08-26T16:29:07.253 に答える