cron 和 server_start.sh 的新手问题

cron 和 server_start.sh 的新手问题

我决定将我的 Valheim 专用服务器放在我的第二台计算机上,该计算机在 Xfce 桌面环境上运行。我让它运行良好,并决定第一次尝试使用 cron。我制作了 bash 文件来关闭服务器并重新启动计算机,并且它在 cron 上运行良好。之后,我希望 cron 通过使用 start_server.sh 文件来启动我的服务器,此时我正在通过终端使用该文件来启动 Valheim 服务器。我尝试用@reboot 来做到这一点,但它似乎根本不起作用。我认为它与 server_start.sh 的工作方式有关,因为我检查了它具有所有权限等等。

这是我为此制作的 crontab:

#Set the hardware clock to keep it in sync with the more accurate system clock.
55 07 * * * /sbin/hwclock --systohc

#Run restnboot.sh that closes Valheim server and restarts computer.
50 08 * * * /home/restnreboot.sh

#Starts Valheim server at reboot.
@reboot sleep 240 && /home/X/steamcmd/start_server.sh

我还尝试将 #!/bin/sh 添加到 sh 文件中。这是start_server.sh:

#!/bin/sh
export templdpath=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
export SteamAppId=892970

echo "Starting server PRESS CTRL-C to exit"

./valheim_server.x86_64 -name "name" -port 2456 -world "name" -password "password" -nographics -batchmode -public 1

export LD_LIBRARY_PATH=$templdpath

如果有人知道我下一步应该做什么,我将不胜感激。谢谢你的时间!

相关内容