0

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?

4
  • ./run.sh is a path relative to your current working directory that might not be the same working directory for cron ... So what seems obvious to you isn't necessarily obvious to cron ... You need to provide the full path instead like for example /home/username/run.sh.
    – Raffa
    Jun 8, 2023 at 17:09
  • Thankyou, so if I understand this correctly I need to add another line to the Cron job that executes the ru.sh file directly rather than through the restart.sh. if that's the case I will need to edit the run.sh file to open up a tmux session or send that command into the tmux session correct? Jun 9, 2023 at 15:25
  • You're welcome ... No, just change tmux send-keys -t VHS "./run.sh" Enter to something like tmux send-keys -t VHS "/home/username/run.sh" Enter i.e. the full path to the run.sh script inside /VHServer/restart.sh
    – Raffa
    Jun 9, 2023 at 15:52
  • all seems to work now! thanks! Jun 11, 2023 at 5:31

0

You must log in to answer this question.

Browse other questions tagged .