7

Before version 1.7.2 I was able to check if the server was running by using a shellscript that checked if server.log.lck was in the Minecraft server directory. I am running multiple servers via screens, so I want to be sure that the server is not running before I start it. Because 1.7.2 introduced a new logging system, this is not possible anymore.

I use a shell script where I have an unique port and an unique screen name for each server.

How can I now determine if the server is running?

5
  • 2
    What operating system are you using? (This is trivial under unix-like systems, so I'm guessing Windows?) Commented Nov 6, 2013 at 20:23
  • I am running Debian.
    – Jacob
    Commented Nov 6, 2013 at 21:26
  • Ah, so using ps isn't a trivial option, because you have more than one process. Commented Nov 6, 2013 at 21:42
  • @SevenSidedDie: Wouldn't you be able to pipe ps into grep and check that way? Also, there might be another lock file that you can check.
    – MBraedley
    Commented Nov 6, 2013 at 22:02
  • @MBraedley Yeah, but if they're all identical commands (differing only by where they're launched), then they will look the same in ps and there's nothing to grep for. I believe you can run using a full path to the jar instead of relative and then you can grep on the directories in the path, but I don't have a system to test that behaviour's reliability on. (My nearest *nix is OS X, and it notoriously tweaks command line tools in ways that make them subtly different.) Commented Nov 6, 2013 at 22:30

1 Answer 1

3

I sorted it out by using the following if in my shell script:

if ! screen -list | grep -q $SCREEN_NAME; then
    ONLINE=1
else
    ONLINE=0
fi

Where $SCREEN_NAME is the server's unique screen name.

1
  • Nice, and a very clean solution. Commented Nov 9, 2013 at 18:21

You must log in to answer this question.

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