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?

  • 2
    What operating system are you using? (This is trivial under unix-like systems, so I'm guessing Windows?) – SevenSidedDie Nov 6 '13 at 20:23
  • I am running Debian. – Jacob Nov 6 '13 at 21:26
  • Ah, so using ps isn't a trivial option, because you have more than one process. – SevenSidedDie Nov 6 '13 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 Nov 6 '13 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.) – SevenSidedDie Nov 6 '13 at 22:30
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.

  • Nice, and a very clean solution. – SevenSidedDie Nov 9 '13 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.