首页 文章

屏幕不是从rc.local开始的

提问于
浏览
1

我有一个问题,我无法在启动时使用rc.local文件启动屏幕会话 . 我开始的具体屏幕是一个龙头Minecraft服务器 .

这是我的rc.local文件:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/pi/Documents/bootlog.sh
/home/spigot1_12/startspigot.sh
exit 0

这是startspigot.sh脚本(使用chmod u x):

#!/bin/bash

cd /home/spigot1_12

boot=$(date)

echo "Starting spigot server in screen \"minecraft\" @  $boot " >> /home/pi/Documents/minecraftlog


screen -S minecraft java -Xms512M -Xmx1008M -jar /home/spigot1_12/spigot-1.12.jar nogui

minecraftlog文件会在每次启动时更新,因此脚本会运行 .

当我运行命令“sudo sh startspigot.sh”时,一切都运行良好 . 启动屏幕并更新minecraftlog文件 . 我可以用“sudo screen -ls”再次找到屏幕

但是,在启动时,“sudo screen -ls”和“screen -ls”都不返回套接字 .

是什么导致这个?只有两个用户是“pi”和root .

提前致谢!

1 回答

  • 1

    在分离模式下运行屏幕(当您没有活动终端时,如在rc.local或crontab中):

    screen -dm -S <session name> <command>

    -d -m以“分离”模式启动屏幕-S创建新会话时,此选项可用于为会话指定有意义的名称 .

相关问题