2017-06-20 106 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創建新會話時,可以使用此選項爲會話指定一個有意義的名稱。