LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Games
User Name
Password
Linux - Games This forum is for all discussion relating to gaming in Linux.

Notices


Reply
  Search this Thread
Old 02-27-2013, 02:45 AM   #1
JoseCuervo
Member
 
Registered: May 2007
Location: North Carolina
Distribution: RHEL 7, CentOS7
Posts: 82

Rep: Reputation: 18
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.
 
Old 02-27-2013, 08:19 AM   #2
yowi
Member
 
Registered: Dec 2002
Location: Au
Distribution: Debian
Posts: 209

Rep: Reputation: 55
inetd will handle the startup.
https://en.wikipedia.org/wiki/Inetd
 
Old 02-27-2013, 10:20 PM   #3
JoseCuervo
Member
 
Registered: May 2007
Location: North Carolina
Distribution: RHEL 7, CentOS7
Posts: 82

Original Poster
Rep: Reputation: 18
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!
 
Old 02-27-2013, 11:55 PM   #4
JoseCuervo
Member
 
Registered: May 2007
Location: North Carolina
Distribution: RHEL 7, CentOS7
Posts: 82

Original Poster
Rep: Reputation: 18
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. http://www.planetminecraft.com/blog/...bodys-playing/ 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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error When Trying to Run Minecraft actyler1012 Linux - Games 2 02-21-2013 05:45 PM
Wondering How to Install JDK Runtime in Manjaro to Run Minecraft nickkourpias Linux - Software 6 12-11-2012 01:41 AM
LXer: Yes, the Raspberry Pi will run Minecraft LXer Syndicated Linux News 0 11-27-2012 06:41 AM
Create and run a bash script BallsOfSteel Programming 9 07-04-2008 12:48 AM
Bash Script Help - Trying to create a variable inside script when run. webaccounts Linux - Newbie 1 06-09-2008 02:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Games

All times are GMT -5. The time now is 12:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration