Ok so I was running a minecraft server in Ubuntu linux without doing anything fancy. It dumps the world and other server files into my home directory. Now thats kinda messy so I would like the world and other server files to go into a file I specify but I cannot figure out how to get it to do that. Does anyone know how to do that?
Move the server jar file to where you want the server files at. Run the server jar from that directory.
Yea I know that's how it works in windows, but apparently not in ubuntu, at least not for me. No matter where I move the jar it still puts it into the home directory.
Edit: Wait I got it, if I run it from terminal then it puts/uses server files in the same directory. Thank you.
Yea I know that's how it works in windows, but apparently not in ubuntu, at least not for me. No matter where I move the jar it still puts it into the home directory.
if you want them in /home/minecraft/world, then just change to that directory prior to running the jar file.
Here are a couple of methods that I have pruned from my much longer script that should give you an idea of how to interact with the server. If you want to see the rest of the code, check out the link in my signature.
INITIAL_MEMORY="1024M"
MAXIMUM_MEMORY="1024M"
SERVER_JAR="/home/minecraft/minecraft_server.jar"
SERVER_ARGS="nogui"
SERVER_COMMAND="java -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_JAR $SERVER_ARGS"
WORLD_LOCATION="/home/minecraft/world"
start() {
# Start the world server.
# Make sure that the server directory exists.
mkdir -p $WORLD_LOCATION
cd $WORLD_LOCATION
# Start the server.
screen -dmS minecraft $SERVER_COMMAND
if [ ! $? = 0 ]; then
printf "Error starting the server.\n"
exit 1
fi
}
sendCommand() {
# Send a command to the world server.
# ARGS: command
local COMMAND
COMMAND=$(printf "$1\r")
screen -S minecraft -p 0 -X stuff "$COMMAND"
if [ ! $? = 0 ]; then
printf "Error sending command to server.\n"
exit 1
fi
}
...
start
...
sendCommand "say The world is about to shut down..."
sendCommand "save-all"
sleep 5
sendCommand "stop"
if you want them in /home/minecraft/world, then just change to that directory prior to running the jar file.
Here are a couple of methods that I have pruned from my much longer script that should give you an idea of how to interact with the server. If you want to see the rest of the code, check out the link in my signature.
INITIAL_MEMORY="1024M"
MAXIMUM_MEMORY="1024M"
SERVER_JAR="/home/minecraft/minecraft_server.jar"
SERVER_ARGS="nogui"
SERVER_COMMAND="java -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_JAR $SERVER_ARGS"
WORLD_LOCATION="/home/minecraft/world"
start() {
# Start the world server.
# Make sure that the server directory exists.
mkdir -p $WORLD_LOCATION
cd $WORLD_LOCATION
# Start the server.
screen -dmS minecraft $SERVER_COMMAND
if [ ! $? = 0 ]; then
printf "Error starting the server.\n"
exit 1
fi
}
sendCommand() {
# Send a command to the world server.
# ARGS: command
local COMMAND
COMMAND=$(printf "$1\r")
screen -S minecraft -p 0 -X stuff "$COMMAND"
if [ ! $? = 0 ]; then
printf "Error sending command to server.\n"
exit 1
fi
}
...
start
...
sendCommand "say The world is about to shut down..."
sendCommand "save-all"
sleep 5
sendCommand "stop"
Yea I know that's how it works in windows, but apparently not in ubuntu, at least not for me. No matter where I move the jar it still puts it into the home directory.Edit: Wait I got it, if I run it from terminal then it puts/uses server files in the same directory. Thank you.
if you want them in /home/minecraft/world, then just change to that directory prior to running the jar file.
Here are a couple of methods that I have pruned from my much longer script that should give you an idea of how to interact with the server. If you want to see the rest of the code, check out the link in my signature.
Thank you.