kkoss:
As far as I know, you can't get back to a session started with nohup, to gracefully shut it down, you'd have to do it within game, if that isn't a possibility, you need to find the pid using 'ps -ux'. And then killing the process 'kill -9 pid'
Or if you only have a single instance of java running, you can save this and execute it.
#!/bin/bash
pid=`pidof java`
kill -9 $pid
exit 0
Save it to a file (ex: shutdownjava.sh), run 'chmod +x nameyougaveit', then you can run it by using ./nameyougaveit
Just want to say thanks for posting this helpful tutorial. I've successfully started up a server and it's been running fine now for 24 hours or so. My problem is I used this command..
to run the server without the screen showing, and now I can't get back into the screen to shut down the server (using the "stop" command). I'm completely new to linux terminal.
Any help is appreciated
Once you've nohup'd a process, I'm not aware of any way to reattach it. You can still kill it, though. Assuming you don't have any other java processes running, you can use the following command to kill the running minecraft server:
kill `pgrep java`
In the future, you'll probably want to take advantage of screen to run the server in the background while still allowing access to it.
Follow the below link for a script I'm using on my server. It is designed to be used as an init script (/etc/init.d/minecraft), but that isn't required. The script will start, stop, and restart the Minecraft server. There is a force option, just in case, but I haven't really needed to use it on my server (except for testing that it worked). It should work in Ubuntu/Debian. It might require minor tweaks for other distros. There are a couple of variables you'll want to change near the top of it.
Edit: It looks like luigiman replied between when I loaded this page and when I replied. His code works for killing the server, but you shouldn't use the -9 argument with kill unless you have no other options. You're more likely to end up with corrupt files if you do.
Another way to close the window is to use a VNC rather than putty. Run the terminal from within the VNC and start minecraft server. Leave the terminal window open but close the VNC and it will stay running. I didn't have screen installed so this worked OK for me.
1. How do I log into my own server? I try, and it says "Disconnected by server: Took too long to login."
2. I'm trying to get a server up, and no one can login.
Do I need to forward some ports or whaterver? I'm using Ubuntu 10.04.
Thanks!
If it is behind a router, you'll need to forward port 25565 (by default) to the server. You'll also probably want to set a static IP for the server unless you know the router will always assign the same IP to that server.
If you are on the same network, you should be able to connect to the server's internal IP address (typically 192.168.x.x with most home routers) to see if the server is actually running. If that works, but others can't connect, the problem is most likely the port not being forwarded.
This is surely more my own linux noobish-ness than minecraft realated but I can not seem to open port 25565
I'm running the alpha server on ubuntu server 9
I have done
sudo ufw allow 25565
sudo ufw allow out 25565
sudo ufw allow 25565/tcp
sudo ufw allow out 25565/tcp
sudo iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 25565 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 25565 -j ACCEPT
and sudo ufw status verbose shows:
To Action From
-- ------ ----
22/tcp (OpenSSH) ALLOW IN Anywhere
25/tcp (Postfix) ALLOW IN Anywhere
80/tcp ALLOW IN Anywhere
443 ALLOW IN Anywhere
25565 ALLOW IN Anywhere
25565/tcp ALLOW IN Anywhere
25565 ALLOW OUT Anywhere
25565/tcp ALLOW OUT Anywhere
Yet connections to port 25565 fail when I have the firewall enabled (sudo ufw enable)
For example canyouseeme.org says "Error: I could not see your service on port (25565) Reason: Connection timed out"
And connections to port 25565 _DO WORK_ when I disable the firewall (sudo ufw disable)
canyouseeme.org says "Success: I can see your service on port (25565)"
I'm obviously not hugely experienced with this so maybe I'm missing something really obvious.
Anyone out there see what I'm missing?
minecraft]# java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
java -version
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-i386)
OpenJDK Client VM (build 14.0-b16, mixed mode)
I have a porblem all I get is:
2010-10-06 16:36:52 [INFO] Starting minecraft server version 0.2.1
2010-10-06 16:36:52 [INFO] Loading properties
2010-10-06 16:36:52 [INFO] Starting Minecraft server on *:25565
2010-10-06 16:36:53 [INFO] Stopping server
I get exactly the same message. Can anyone please help with this?
I've also got the same problem looking for a solution :\ It's a pain! =.="
Im having a problem hosting from home. Im on a high speed cable connection with rogers (10mb down, /.8mbs up) The server is a dual core 2.2ghz cpu with 8gb ram.
Its running arch linux. When people join they get one of three different things to happen. 1) They connect and fall through the world. 2) The world barely generates (less then 20x20 squares). 3) A larger area grows but they are unable to destroy anything.
Please help. I have posted before and I have been on the irc but got no help.
Im having a problem hosting from home. Im on a high speed cable connection with rogers (10mb down, /.8mbs up) The server is a dual core 2.2ghz cpu with 8gb ram.
Its running arch linux. When people join they get one of three different things to happen. 1) They connect and fall through the world. 2) The world barely generates (less then 20x20 squares). 3) A larger area grows but they are unable to destroy anything.
Please help. I have posted before and I have been on the irc but got no help.
What model of router are you using?
If you connect to the server via the internal IP (typically 192.168.x.x), do you experience the same problem?
0.8mbps up wont be enough for a server. You need at least a couple for some stable connection for a couple of users. Most servers usually have 100mbps up, or 10mbps up
That is a real shame that .8mbs is to little. Thats the most I can get within my area.
I have a porblem all I get is:
2010-10-06 16:36:52 [INFO] Starting minecraft server version 0.2.1
2010-10-06 16:36:52 [INFO] Loading properties
2010-10-06 16:36:52 [INFO] Starting Minecraft server on *:25565
2010-10-06 16:36:53 [INFO] Stopping server
I get exactly the same message. Can anyone please help with this?
I've also got the same problem looking for a solution :\ It's a pain! =.="
I had that problem before.
Now after trying to install again I'm getting this problem:
java -version
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-i386)
OpenJDK Client VM (build 14.0-b16, mixed mode)
minecraft]# java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
java -version
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-i386)
OpenJDK Client VM (build 14.0-b16, mixed mode)
Does survival mode even exist for the Multiplayer yet? And I've been having a difficult time creating a waterfall after the tutorials I've watched online. Any ideas? The water blocks I drop don't flow period they just sit for 5 seconds then poof! Gone... Is there some bigger server configuration I'm missing out on here?
I would do it a little more like this (the initial setup and first start) for a Cent0s box, especially since the vast majority of cheap vps setups run Cent0s by default.
As soon as your server is "powered on", you want to connect to it via SSH. Download putty and use that to connect to your server's IP address. You should be greeted with a prompt that asks you for a username. You will enter "root" and use the root password provided by your hosting company. I know you're anxious to get things up and running, but security comes first! Follow these steps once you are logged in:
1. Change the root password.
type "passwd"
follow the prompts
2. Make a new user account. My example user will be named "bob" (choose your own, of course - I'll keep using "bob" in this guide)
type "addusr bob"
type "passwd bob"
follow the prompts
3. Now let's give bob "sudo" priveleges so that he can do everything necessary to manage the system.
type "vi /etc/sudoers"
hit "i" to start editing
find the line that says "root ALL=(ALL) ALL"
add a new line "bob ALL=(ALL) ALL"
hit ESC and then type ":x!" and hit enter to exit.
4. Time to disable root from logging in to the shell. You will NEVER log in as root again. EVER.
type "vi /etc/ssh/sshd_config"
hit "i" to start editing
look for a line that starts with "PermitRootLogin". If it exists, change it to "PermitRootLogin no".
if the line does not exist, add "PermitRootLogin no" (anywhere on its own line)
hit ESC and then type ":x!" and hit enter to exit.
type "service sshd restart"
5. Without closing your current SSH/Telnet window, open a new instance of putty and log in as bob. Once logged in:
type "su -"
You may see a prompt about responsiblity. Follow the directions if so.
You will be asked for the password. This is *your* password, not the root password.
If the password worked, close your original telnet window (that is logged in as root).
6. The account "bob" is your account. This is your account that you log in with to perform day to day tasks, or whatever you think is necessary. You will *not* be running things under this account if at all possible. Let's make another account just for running minecraft.
type "addusr minecraftuser"
type "passwd minecraftuser"
follow the prompts
7. Now we need to make a group for this user.
type "useradd -G minecraftgroup minecraftuser"
type "useradd -G minecraftgroup bob"
this creates the group minecraftgroup and makes minecraftuser a member. We also want bob in this group so he can
make changes to the same files that minecraftuser can.
8. Time to make a directory for the mincraft software. A lot of this depends on personal preference, but since this server's primary (and perhaps only) function is being minecraft server, I generally place it directly in the root of the drive. We also need to set some permissions on this folder.
type "mkdir /mc"
type "chgrp -hr minecraftgroup /mc"
type "chmod -R 770 /mc
This creates /mc, and allows users in the group "minecraftgroup" full access
9. Time to install java. You still still be logged in as root, (if not, do so by issuing the "su -" command once logged in)
type "yum install java"
you will see a bunch of information; just answer yes to everything
10. Next we need to get minecraft installed. You'll want to do this as the minecraft user account (so you don't have to fix file permissions later). Log back in as minecraftuser, or just issue the "su minecraftuser" command to switch back.
type "cd /mc"
type "mkdir server"
type "cd server"
type "vi launch_minecraft.sh"
hit "i" to start editing and add the following two lines (wthout quotes):
(note that the 1024 here is the amount of memory reserved for minecraft. Increase or lower this as needed to match what you can spare).
hit escape and type ":x!" and hit enter to exit.
switch back to root with the "su -" command, and type the following:
"sudo wget http://www.minecraft.net/download/minecraft_server.jar"
"cd /mc"
"chgrp -R minecraftgroup /mc"
"chown -R minecraftgroup /mc"
"chmod +x /mc/server/launch_minecraft.sh"
11. Time to launch mincecraft for the first time. Switch back to minecraftuser and do the following:
type "/mc/server/launch_minecraft.sh"
You should see a bunch of text on the screen from the minecraft process. Let it get up and running, and then type "stop" and hit enter.
It will take a few moments, but the process will end and you will be back at the command prompt. Also notice that there are a LOT more files in your server directory now.
12. Launching minecraft normally
Use one of the MANY available guides to configure your minecraft settings before doing this.
Make sure you are logged in as minecraftuser and type "/mc/server/launch_minecraft.sh"
This time, instead of stopping the server, hit ctrl+A+D to exit the screen. Minecraft will still be running, and you can go back to it at any
time by typing "screen -r".
A word of caution: You really need to take a good hard look at security. Running a linux server without the proper hardening can get you in serious trouble. I would guide you through this, but there are already several excellent guides out there. Google is your friend. In general, make sure you have iptables running, install fail2ban, consider installing clamAV, etc. But technically speaking, your server is up at this point.
In general, make sure you have iptables running...
Word of advice to anyone new to iptables. IPTables unlike Windows firewalls, unless you specify -m state --state NEW, those rules will kick in realtime, like the instant you press down on the enter key to append a new rule to a table chain. It is very easy to iptable yourself out of a remote server. Hopefully your first attempts will be to configure a LAN server with a monitor and keyboard plugged into it and test remoting into it from another LAN machine.
You would need to use screen for that. Here's a guide for it, http://www.howtoforge.com/linux_screen
kkoss:
As far as I know, you can't get back to a session started with nohup, to gracefully shut it down, you'd have to do it within game, if that isn't a possibility, you need to find the pid using 'ps -ux'. And then killing the process 'kill -9 pid'
Or if you only have a single instance of java running, you can save this and execute it.
Save it to a file (ex: shutdownjava.sh), run 'chmod +x nameyougaveit', then you can run it by using ./nameyougaveit
Once you've nohup'd a process, I'm not aware of any way to reattach it. You can still kill it, though. Assuming you don't have any other java processes running, you can use the following command to kill the running minecraft server:
In the future, you'll probably want to take advantage of screen to run the server in the background while still allowing access to it.
Follow the below link for a script I'm using on my server. It is designed to be used as an init script (/etc/init.d/minecraft), but that isn't required. The script will start, stop, and restart the Minecraft server. There is a force option, just in case, but I haven't really needed to use it on my server (except for testing that it worked). It should work in Ubuntu/Debian. It might require minor tweaks for other distros. There are a couple of variables you'll want to change near the top of it.
http://pastebin.com/Th9GQv2g
Edit: It looks like luigiman replied between when I loaded this page and when I replied. His code works for killing the server, but you shouldn't use the -9 argument with kill unless you have no other options. You're more likely to end up with corrupt files if you do.
--
Andy
1. How do I log into my own server? I try, and it says "Disconnected by server: Took too long to login."
2. I'm trying to get a server up, and no one can login.
Do I need to forward some ports or whaterver? I'm using Ubuntu 10.04.
Thanks!
Been playing Minecraft since 1.1.2_01.
If it is behind a router, you'll need to forward port 25565 (by default) to the server. You'll also probably want to set a static IP for the server unless you know the router will always assign the same IP to that server.
If you are on the same network, you should be able to connect to the server's internal IP address (typically 192.168.x.x with most home routers) to see if the server is actually running. If that works, but others can't connect, the problem is most likely the port not being forwarded.
--
Andy
I'm running the alpha server on ubuntu server 9
I have done
sudo ufw allow 25565
sudo ufw allow out 25565
sudo ufw allow 25565/tcp
sudo ufw allow out 25565/tcp
sudo iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 25565 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 25565 -j ACCEPT
and sudo ufw status verbose shows:
To Action From
-- ------ ----
22/tcp (OpenSSH) ALLOW IN Anywhere
25/tcp (Postfix) ALLOW IN Anywhere
80/tcp ALLOW IN Anywhere
443 ALLOW IN Anywhere
25565 ALLOW IN Anywhere
25565/tcp ALLOW IN Anywhere
25565 ALLOW OUT Anywhere
25565/tcp ALLOW OUT Anywhere
Yet connections to port 25565 fail when I have the firewall enabled (sudo ufw enable)
For example canyouseeme.org says "Error: I could not see your service on port (25565) Reason: Connection timed out"
And connections to port 25565 _DO WORK_ when I disable the firewall (sudo ufw disable)
canyouseeme.org says "Success: I can see your service on port (25565)"
I'm obviously not hugely experienced with this so maybe I'm missing something really obvious.
Anyone out there see what I'm missing?
Keep getting that idk whats wrong
I've also got the same problem looking for a solution :\ It's a pain! =.="
Its running arch linux. When people join they get one of three different things to happen. 1) They connect and fall through the world. 2) The world barely generates (less then 20x20 squares). 3) A larger area grows but they are unable to destroy anything.
Please help. I have posted before and I have been on the irc but got no help.
What model of router are you using?
If you connect to the server via the internal IP (typically 192.168.x.x), do you experience the same problem?
If i use localhost to connect or use my dyndns or ip i connect fine. Some times it crashes but most the time it is fine.
The server is running java hotspot. Im not sure how to ensure this is the newest version.
That is a real shame that .8mbs is to little. Thats the most I can get within my area.
I had that problem before.
Now after trying to install again I'm getting this problem:
If there is any more information I needed I will gladly do what I can.
Also I tried without the "www" like in the tutorial, the error was the same.
I don't know what's wrong.
Help please?
viewtopic.php?f=25&t=74564
As soon as your server is "powered on", you want to connect to it via SSH. Download putty and use that to connect to your server's IP address. You should be greeted with a prompt that asks you for a username. You will enter "root" and use the root password provided by your hosting company. I know you're anxious to get things up and running, but security comes first! Follow these steps once you are logged in:
1. Change the root password.
type "passwd"
follow the prompts
2. Make a new user account. My example user will be named "bob" (choose your own, of course - I'll keep using "bob" in this guide)
type "addusr bob"
type "passwd bob"
follow the prompts
3. Now let's give bob "sudo" priveleges so that he can do everything necessary to manage the system.
type "vi /etc/sudoers"
hit "i" to start editing
find the line that says "root ALL=(ALL) ALL"
add a new line "bob ALL=(ALL) ALL"
hit ESC and then type ":x!" and hit enter to exit.
4. Time to disable root from logging in to the shell. You will NEVER log in as root again. EVER.
type "vi /etc/ssh/sshd_config"
hit "i" to start editing
look for a line that starts with "PermitRootLogin". If it exists, change it to "PermitRootLogin no".
if the line does not exist, add "PermitRootLogin no" (anywhere on its own line)
hit ESC and then type ":x!" and hit enter to exit.
type "service sshd restart"
5. Without closing your current SSH/Telnet window, open a new instance of putty and log in as bob. Once logged in:
type "su -"
You may see a prompt about responsiblity. Follow the directions if so.
You will be asked for the password. This is *your* password, not the root password.
If the password worked, close your original telnet window (that is logged in as root).
6. The account "bob" is your account. This is your account that you log in with to perform day to day tasks, or whatever you think is necessary. You will *not* be running things under this account if at all possible. Let's make another account just for running minecraft.
type "addusr minecraftuser"
type "passwd minecraftuser"
follow the prompts
7. Now we need to make a group for this user.
type "useradd -G minecraftgroup minecraftuser"
type "useradd -G minecraftgroup bob"
this creates the group minecraftgroup and makes minecraftuser a member. We also want bob in this group so he can
make changes to the same files that minecraftuser can.
8. Time to make a directory for the mincraft software. A lot of this depends on personal preference, but since this server's primary (and perhaps only) function is being minecraft server, I generally place it directly in the root of the drive. We also need to set some permissions on this folder.
type "mkdir /mc"
type "chgrp -hr minecraftgroup /mc"
type "chmod -R 770 /mc
This creates /mc, and allows users in the group "minecraftgroup" full access
9. Time to install java. You still still be logged in as root, (if not, do so by issuing the "su -" command once logged in)
type "yum install java"
you will see a bunch of information; just answer yes to everything
10. Next we need to get minecraft installed. You'll want to do this as the minecraft user account (so you don't have to fix file permissions later). Log back in as minecraftuser, or just issue the "su minecraftuser" command to switch back.
type "cd /mc"
type "mkdir server"
type "cd server"
type "vi launch_minecraft.sh"
hit "i" to start editing and add the following two lines (wthout quotes):
"cd /mc/server"
"screen -dmS mcserver java -jar -Xmx1024M -Xms1024M minecraft_server.jar"
(note that the 1024 here is the amount of memory reserved for minecraft. Increase or lower this as needed to match what you can spare).
hit escape and type ":x!" and hit enter to exit.
switch back to root with the "su -" command, and type the following:
"sudo wget http://www.minecraft.net/download/minecraft_server.jar"
"cd /mc"
"chgrp -R minecraftgroup /mc"
"chown -R minecraftgroup /mc"
"chmod +x /mc/server/launch_minecraft.sh"
11. Time to launch mincecraft for the first time. Switch back to minecraftuser and do the following:
type "/mc/server/launch_minecraft.sh"
You should see a bunch of text on the screen from the minecraft process. Let it get up and running, and then type "stop" and hit enter.
It will take a few moments, but the process will end and you will be back at the command prompt. Also notice that there are a LOT more files in your server directory now.
12. Launching minecraft normally
Use one of the MANY available guides to configure your minecraft settings before doing this.
Make sure you are logged in as minecraftuser and type "/mc/server/launch_minecraft.sh"
This time, instead of stopping the server, hit ctrl+A+D to exit the screen. Minecraft will still be running, and you can go back to it at any
time by typing "screen -r".
A word of caution: You really need to take a good hard look at security. Running a linux server without the proper hardening can get you in serious trouble. I would guide you through this, but there are already several excellent guides out there. Google is your friend. In general, make sure you have iptables running, install fail2ban, consider installing clamAV, etc. But technically speaking, your server is up at this point.
Word of advice to anyone new to iptables. IPTables unlike Windows firewalls, unless you specify -m state --state NEW, those rules will kick in realtime, like the instant you press down on the enter key to append a new rule to a table chain. It is very easy to iptable yourself out of a remote server. Hopefully your first attempts will be to configure a LAN server with a monitor and keyboard plugged into it and test remoting into it from another LAN machine.