Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've been searching to try to find the information I need, but I have so far been unsuccessful.

What I would like to have happen daily is the following:

  • Every time the machine starts, the Minecraft server is started. (I have the shell commands already written for this.)
  • At 8:00 AM, the text "stop" is submitted to the server to cause it to gracefully stop.
  • At 8:02 AM, the computer restarts.

Ideally, this will open a window on my desktop that enter commands into, and also have a way to send commands to the server through a remote terminal.

How do I do this? I have found information on using sudo crontab -e in order to allow super-user access needed to run the Minecraft server. I have also looked into using named pipes, but I can't quite get it working right. I can create it with mkfifo mcserver, but it blocks unless I open the pipe in another terminal. I have also looked into screen, as well as echoing commands to a directory based on the pid, but I have not been able to get that to work either. How would I detect and store the pid?

Thank you for your help. It's greatly appreciated. I've been struggling with this for quite a while, and I just can't seem to figure it out.

share|improve this question

migrated from stackoverflow.com Jul 28 '12 at 14:31

This question came from our site for professional and enthusiast programmers.

    
What exactly are you asking? You want the MineCraft server box to restart, then to open a connection, allowing you to connect to it, and manage it, from a remote machine? –  plast1K Jul 28 '12 at 2:55
    
If you could help me migrate this to the correct forum, I would appreciate that as well. –  user1559027 Jul 28 '12 at 3:10
    
I would like to be able to manage it from a remote machine, yes. Most important is the daily graceful stop, reboot, and application start. –  user1559027 Jul 28 '12 at 3:11
4  
Why do you want to reboot your computer every day? Linux systems shouldn't need periodic rebooting. –  cjm Jul 28 '12 at 18:50

2 Answers 2

Use this script

Then set your crontab for root up like this:

0 8 * * * service minecraft stop
2 8 * * * reboot

Then run

chkconfig minecraft on 

to add the minecraft service to automatic start on boot.

share|improve this answer

You could try using 'netcat'....

nc -l -p <port> -e /bin/bash

I can't say that this is in anyway secure; and I don't necessarily condone doing it. Basically, this will literally BIND your BASH shell to a port of your choosing. This is known as a "Reverse shell", and would most likely make your machine vulnerable; unless your firewall is configured properly. [iptables] Or some other method.

So you connect to your machine remotely, with netcat, by using:

nc <remote_ip> <port>

And it will provide an interface to send commands.

An alternative method would be to simply create a script that runs a listening VNC server, so you could connect remotely and manage it visually. All of these options require care when connecting remotely and having opened ports [on a server].

I assume this is what you are asking. Make a small BASH script and this is cake. Or add it to your .rc files, and it will go automatically.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.