I want to setup a minecraft server on my Ubuntu server. I'm having a really hard time setting it up. I tried the directions on this page http://minecraft.gamepedia.com/Tutorials/Ubuntu_startup_script. but it did not work.
So how would you setup a minecraft server to start on system boot after following theses simple directions which do work for me(https://www.digitalocean.com/community/tutorials/how-to-set-up-a-minecraft-server-on-linux)?
Thanks. I'm setting this up for my sister so me and her can play.
You can edit the rc.local file and have it run a screen call so that mc doesn't stop the boot process. Could also do upstart script. I've done the first one before
create a script file. then make an cron job for it to start on reboot, anytime the server reboots it will run the script and start the server.
Could you write me a script? I've made scripts before but nothing that complicated. Would it just contain the line
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui?
Sorry I'm still a noob
#!/bin/bash
whatever commands you use to start the server
that's it, just make the file executable by running chmod +x /path/to/file
then run crontab -e and add @reboot /path/to/script
This is what I have so far.
In my minecraft directory I have a script called myscript with x permissions. Inside the script I have one line
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
and that's it. When I run the script with ./myscript. It works and I can connect to the server through the client software on another computer.
However when I do the crontabe -e and added the one line of @reboot /home/username/minecraft/myscript it will not work when I reboot the machine. By won't work I mean I can't connect on the client software as before.
screen -dmX minecraft path/to/start/script
That is how I always start my servers up. Then they don't block terminal and can be looked at if meeded
Add #!/bin/bash to the top of the script
That didn't seem to work for me
Well, thanks everyone with you help I got it working! Thanks Dexter_Kane for that final piece of help. Got it working with that. Thanks. Sorry I've been so spotty at replying. It's been a busy weekend.
No worries. You need that line at the top of the script so the thing launching the script knows what to run it with. You can also run it using the command /bin/bash yourscript.sh but having that line allows you to run it like a program without having to run it using bash.
Okay so I guess I lied it isn't working. I think I was running while I did it manual so I thougght it was working. Spoke to soon.
Anyway when I run the script it works with ./myscript. But will not start on boot. In rc.local I have a line with
sh /somthingelse/anotherscript
sh /home/user/minecraft/myscript
exit 0
change this to /bin/bash /home/user/minecraft/myscript
If that doesn't work remove it from rc.local or comment it out and then run crontab -e and add this:
@reboot sleep 30; /bin/bash /home/minecraft/myscript
This will add a 30 second delay before it starts which can help sometimes as it needs to wait for other things to load before it can run.
You should look at converting it to a systemd or upstart (depending on which version of ubuntu you're using) script instead but I'm not sure how to do that.
Nither worked. I tried both and was very careful about typo's
I'm not sure why it's not working.
Considering it's just a single command try adding it to cron like this:
@reboot java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
Actually looking at that you may need to use an absolute path for that .jar file, try that aswell.
Okay I did some testing around. Before, I tried running it in directory of the script with ./myscript. I decided to test it outside the directory running calling the script manually. This is what I did from inside the minecraft directory.
cd ..
./minecraft/myscript
First one takes me out of the directory and than I try and run it from outside. I get this error:
Error: Unable to access jarfile minecraft_server.jar
So the script works when I am calling it from inside the directory but not when I am outside.
Yeah, you need an absolute path for that .jar file
EDIT: change it to /home/user/minecraft/minecraft_server.jar
It's dumping files in my home directory. So it does work but it fails to start because EULA isn't set to true which it is in the minecraft directory. I did an ls in home and found that it made a new properties file and a new EULA in my home. Why is it doing that
java -Xmx1024M -Xms1024M -jar /home/user/minecraft/minecraft_server.jar nogui
Is the command inside of the script