![如何每 24 小时重启修改过的 Minecraft 服务器?](https://linux22.com/image/1195311/%E5%A6%82%E4%BD%95%E6%AF%8F%2024%20%E5%B0%8F%E6%97%B6%E9%87%8D%E5%90%AF%E4%BF%AE%E6%94%B9%E8%BF%87%E7%9A%84%20Minecraft%20%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%9F.png)
我制作了一个.SH
如下所示的文件:
让人们知道服务器将要重新启动:
tmux send-keys -t VHS "/say §cServer restarting in §l30 minutes. §rPlease get ready to log off." Enter
# Wait for 1770 seconds (29 minutes and 30 seconds)
sleep 1770s
向服务器发送重启倒计时消息:
tmux send-keys -t VHS "/say §cServer is restarting in §l30 seconds! §rthe restart will take aproximately 5 minutes!" Enter
sleep 20s
tmux send-keys -t VHS "/say §cServer is restarting in §l10 seconds!" Enter
sleep 5s
tmux send-keys -t VHS "/say §cServer is restarting in §l5 seconds!" Enter
sleep 1s
tmux send-keys -t VHS "/say §cServer is restarting in §l4 seconds!" Enter
sleep 1s
tmux send-keys -t VHS "/say §cServer is restarting in §l3 seconds!" Enter
sleep 1s
tmux send-keys -t VHS "/say §cServer is restarting in §l2 seconds!" Enter
sleep 1s
tmux send-keys -t VHS "/say §cServer is restarting in §l1 second!" Enter
sleep 1s
停止 Minecraft 服务器:
tmux send-keys -t VHS "/stop" Enter
sleep 300s
使用脚本重新启动服务器run.sh
:
tmux send-keys -t VHS "./run.sh" Enter
我为 crontab 编写的代码行如下所示:
0 21 * * * /VHServer/restart.sh
该.sh
文件似乎运行了除/stop
命令和可能./run.sh
为服务器设置的所有内容,可以请我解释一下原因吗?