Crontab 似乎不起作用

Crontab 似乎不起作用

我在屏幕上运行我的 minecraft 服务器,并且设置了一个脚本来在crontab每天晚上 3 点重新启动服务器。

restart.sh

#!/bin/sh
echo "Letting people know that the server is going to restart...."
screen -R mc -X stuff "say Server is restarting in 1 minute! $(printf '\r')"
sleep 30s
screen -R mc -X stuff "say Server is restarting in 30 seconds! $(printf '\r')"
sleep 20s
screen -R mc -X stuff "say Server is restarting in 10 seconds! $(printf '\r')"
sleep 5s
screen -R mc -X stuff "say Server is restarting in 5 seconds! $(printf '\r')"
sleep 1s
screen -R mc -X stuff "say Server is restarting in 4 seconds! $(printf '\r')"
sleep 1s
screen -R mc -X stuff "say Server is restarting in 3 seconds! $(printf '\r')"
sleep 1s
screen -R mc -X stuff "say Server is restarting in 2 seconds! $(printf '\r')"
sleep 1s
screen -R mc -X stuff "say Server is restarting in 1 second! $(printf '\r')"
sleep 1s
screen -R mc -X stuff "stop $(printf '\r')"
sleep 15s
screen -R mc -X stuff "bash start.sh $(printf '\r')"
echo "Done"

当我自己运行此代码时,它运行完美。它发送聊天中的所有消息,然后重新启动,但无论我多么努力,crontab它就是无法运行。

这是我在 minecraft 用户中的代码crontab

0 3 * * * /home/minecraft/server/restart.sh

相关内容