Tools
Scheduled server restarts
Pick the restart time and how many minutes ahead to warn to get crontab lines: the server tells players in chat and gets stop on time. systemd with Restart=always or a loop in the start script brings it back.
Scheduled restart
crontab lines
45 4 * * * tmux send-keys -t mc "say Server restarts in 15 min." Enter 55 4 * * * tmux send-keys -t mc "say Server restarts in 5 min." Enter 59 4 * * * tmux send-keys -t mc "say Server restarts in 1 min." Enter 0 5 * * * tmux send-keys -t mc "say Restarting! Back in a minute." Enter 0 5 * * * sleep 5 && tmux send-keys -t mc "stop" Enter
sudo -u minecraft crontab -eWhy restart a server, and how this works
A planned daily restart is common practice: the server reloads plugins and the world fresh, and players know the time in advance. The generator writes lines for cron, the Linux scheduler: at the right minutes it sends say with a warning to the server console, and stop at the set time.
The commands reach the console through tmux send-keys — that's how our systemd unit runs the server: the console lives in a tmux session. stop saves the worlds cleanly. systemd with Restart=always, or a start script with auto-restart, brings the server back.
cron uses the machine's time and time zone. Add the lines to the crontab of the user the server runs as: sudo -u minecraft crontab -e. Check they're there with crontab -l as the same user.
If the server lags so much it needs frequent restarts, find the cause with the spark profiler. DGuard uses 0.03% of one core on the main thread — the anticheat won't be the reason you restart.
Read in the knowledge base
FAQ
How do I restart a Minecraft server automatically?
Add the generator's lines to crontab: they warn players and send stop at the set time. For the server to come back, systemd with Restart=always or a loop in the start script must restart it.
Why did the server stop and not start again?
stop only stops the server. Starting it again is the job of systemd with Restart=always or a loop in start.sh — without them it stays off.
Which time zone does cron use?
The machine's. Check it with date and set the times accordingly.
Can I do this on a host with a control panel?
If you don't have cron access, check whether your host's panel has a task scheduler: there you can set up restarts without crontab lines.
The tools are free. So is anti-cheat protection
DGuard — the best anticheat for a modern Minecraft server — catches all 47 cheat types in our comparison; the nearest rival, Intave, catches 27. Free up to 30 players online, with the same protection as on paid plans.