2017-06-20 128 views
0

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

这是我的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

Stack Overflow是编程和开发问题的网站。这个问题似乎与题目无关,因为它不涉及编程或开发。请参阅帮助中心的[我可以询问哪些主题](http://stackoverflow.com/help/on-topic)。也许[超级用户](http://superuser.com/)或[Unix&Linux堆栈交换](http://unix.stackexchange.com/)会是一个更好的地方。 – jww

回答

0

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

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

-d -m在 “分离” 模式

启动画面

-S创建新会话时,可以使用此选项为会话指定一个有意义的名称。