OPTIONS="java -Xms1024M -Xmx1024M -jar craftbukkit.jar"
PROCESS=server01
screen -dmS $PROCESS $OPTIONS nogui # Starting the application
screen -x $PROCESS -X stuff `printf "stop\r"` # Closing the application
screen -x $PROCESS # Attaching to the terminal of the application
该应用程序在开始时运行良好,但是我在使用 stuff 'printf "stop/r"'
时遇到问题
刚启动的时候好像不行,等了一段时间再尝试用上面的命令停止。但奇怪的是,如果我执行了 screen -x $PROCESS
和 detach (ctrl-A & ctrl-D
) 然后我使用了 Stop
命令它确实有效。那么有没有办法在没有screen -x $PROCESS
的情况下stuff printf
?
最佳答案
添加参数 -p 0 应该可以解决这个问题。像这样:
screen -x $PROCESS -p 0 -X stuff `printf "stop\r"`
(来自 screen 文档:-p window 如果存在,则预选指定的窗口。)
关于linux - Shell GNU-Screen -X Stuff 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13829310/