Minecraft Server (Auto start scripts)
Posted: Wed Dec 06, 2023 6:13 pm
This script allow to send message when you restart or shutdown the server warning the users
this script on ubuntu server go on
make a file with the name what ever you like
copy this code and change the parts you need
save the file with the keys CTRL + X confirm with Y and enter
for make the server autostart when you turn on put this
and start the server or restart the server and the minecraft server start automatically
this script on ubuntu server go on
Code: Select all
bash#: /etc/systemd/systemCode: Select all
bash#: /etc/systemd/system/nano chooseyourname.serviceCode: Select all
[Unit]
Description=Minecraft Dedicated Server
Documentation=https://yourwebsite
After=network.target
[Service]
RemainAfterExit=yes
WorkingDirectory=/home/youruser/Server
User=kosmito
# Start Screen, Java, and Minecraft
ExecStart=screen -s mc -d -m java -Xms3196M -Xmx5396M -jar server.jar nogui # change the memory depending of your server ( delete this )
# Tell Minecraft to gracefully stop.
# Ending Minecraft will terminate Java
# systemd will kill Screen after the 60-second delay. No explicit kill for Screen needed
ExecStop=screen -p 0 -S mc -X eval 'stuff "say SERVER SHUTTING DOWN OR MAYBE RESTART?. Saving map..>
ExecStop=screen -p 0 -S mc -X eval 'stuff "save-all"\015'
ExecStop=screen -p 0 -S mc -X eval 'stuff "stop"\015'
ExecStop=sleep 60
[Install]
WantedBy=multi-user.targetfor make the server autostart when you turn on put this
Code: Select all
bash#: systemctl enable yournamefile.service