Categories
Development Linux Ubuntu

Crontab doesn’t seem to work

i run my minecraft server in a screen and i have a script set up to restart the server via crontab every night at 3 am.

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"

this code works perfectly when i run it myself, it sends all the messages in the chat and then restarts but no matter how hard i wish, crontab just will not run it.

this is the code i have in the minecraft users crontab

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

Leave a Reply

Your email address will not be published. Required fields are marked *