0

I have a minecraft server running in screen, and right now, it is just a script that starts java like so:

screen -dmS mc java -Xincgc -Xms1024M -jar craftbukkit-1.6.4-b2882.jar

Basically this just starts minecraft in a screen container in the background, and I can access it with screen -r mc through SSH. However, what I would like to do, is have the process always up on the server monitor, and also accessible through ssh with screen -x mc. Also, I have a restart.sh script that stuffs the stop command to the mc process every two hours, then it executes the start.sh script. The server is at runlevel 3, so I don't think gnome-terminal -e "screen -x mc" will work. Also, it seems like the restart script is starting mc outside of screen. When I SSH into the server, screen -ls turns up nothing, but the minecraft server process is running and I can connect to it. Here's the script:

#!/bin/sh

screen -x mc
screen -s mc stuff "say Server Restarting in 15 minutes."
screen -s mc -X eval "stuff \015"
sleep 600
screen -x mc
screen -x mc -X stuff "say Server restarting in 5 minutes."
screen -s mc -X eval "stuff \015"
sleep 240
screen -x mc
screen -s mc -X stuff "say Server restarting in 1 minute."
screen -s mc -X eval "stuff \015"
sleep 60
screen -S mc -X stuff "say Server restarting."
screen -S mc -X eval "stuff \015"
screen -S -X stuff "kickall Server Restarting, it should be back up in about a minute."
screen -S mc -X eval "stuff \015"
sleep 2
screen -S mc -X stuff "stop"
screen -S mc -X eval "stuff \015"
sleep 30
screen -wipe
sleep 3
cd /minecraft/server/craftbukkit
./start.sh

Any ideas?

2
  • You said screen -ls doesn't show any processes. Are you checking as the right user? Check the pstree command to show the parent process of the java command; if it is running inside screen, use lsof -p <screenpid> to see what the name of the screen session is (it's one of the open unix socket names). Sep 23, 2013 at 20:56
  • Thank you @Andrew, I think that was the issue, I was running restart.sh as root. Sep 24, 2013 at 12:22

1 Answer 1

0

A better approach, in my opinion, would be to use an init script to manage your application.

Some examples :

Ensure that your process logs its output to a file and using "tail -f" command you will be able to "have the process always up on the server monitor, and also accessible through ssh"

1
  • I like the idea of using an init script to manage the process, but I don't think tail will work, since I also want to be able to execute commands from the server itself. Sep 24, 2013 at 12:22

Not the answer you're looking for? Browse other questions tagged .