-   Linux - Games (
-   -   Create a script to run Minecraft when a player connects (

JoseCuervo 02-27-2013 03:45 AM

Create a script to run Minecraft when a player connects
I have installed a Minecraft Server on an Ubuntu Server install. Everything works fine, my router is properly port forwarded, and I can play on the server from other computers on my network as well. The machine hosting minecraft is going to be a 24/7 box, and I want it to be as power conscious as possible. Low power CPU, spin down the hard drives, and a .6 watt SSD. I don't want Minecraft to be running all of the time, since java is a CPU hog and will drive up the electricity usage. (I am aware that adding .03kW/hrs is still very cheap, but humor me please :) )

How can I set up a script that detects when someone is connecting to port 25565 on the server box and then starts the Minecraft server? Minecraft takes .6 seconds to start, so the reaction time of getting the server up after someone makes a connection is small. Bonus points if you can A: tell me how to start Minecraft in a RamDisk as well, and B: tell me how to close Minecraft after all players disconnect.

At first I was just going to start a ramdisk, start Minecraft, and then let it run forever, but I'm planning a wedding, going to school, and working nights, so my Minecraft time alternates between an hour a day and an hour every two months. Since this box will mostly be for file sharing, I don't need Minecraft running all the time.

yowi 02-27-2013 09:19 AM

inetd will handle the startup.

JoseCuervo 02-27-2013 11:20 PM

Thanks for pointing me at inetd, I've jumped to xinetd now and I'm looking at how to implement it. I appreciate the tip!

JoseCuervo 02-28-2013 12:55 AM

In case anyone else wants to do this to Minecraft on Ubuntu Server, I found a useful website where someone has already done pretty much what I wanted. shows how to catch an incoming Minecraft connection with xinetd, start the minecraft service, and even close minecraft after 15 minutes of disuse with cron. I'm getting it working on my system now, and I'll update anything I learn or questions that I have.

All times are GMT -5. The time now is 11:38 AM.