I made a .SH
file that looks like this:
Letting people know that the server is going to restart:
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
Send messages to the server indicating the restart countdown:
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
Stop the Minecraft server:
tmux send-keys -t VHS "/stop" Enter
sleep 300s
Restart the server using the run.sh
script:
tmux send-keys -t VHS "./run.sh" Enter
And the line of code I have made for the crontab looks like this:
0 21 * * * /VHServer/restart.sh
The .sh
file seems to run everything but the /stop
command and possibly the ./run.sh
I have set up for the server, can I please get an explanation why?
./run.sh
is a path relative to your current working directory that might not be the same working directory forcron
... So what seems obvious to you isn't necessarily obvious tocron
... You need to provide the full path instead like for example/home/username/run.sh
.tmux send-keys -t VHS "./run.sh" Enter
to something liketmux send-keys -t VHS "/home/username/run.sh" Enter
i.e. the full path to therun.sh
script inside/VHServer/restart.sh