Jump to content

Keep Linux server running when closing the connection


Recommended Posts

  • MTA Team

You finally have your brand new dedicated server, you upload the MTA server with ftp, you configure your config file and start the server.

normal.jpg

But then : disaster. When you close your ssh connection the server drops dead.

Well, at least you have gotten this far. Congratulations. The server closes when you close your session because the server is running on your current terminal. When your session closes the terminal closes and terminates the server. There are 2 ways to get passed this problem.

Starting the server in background mode

Most command line programs have a small build-in help system that allows you to see options. You can see these by using the -? swith. For MTA that would be

./MTAServer -?

The output will look like:

help.jpg

We need to run our server in the background so:

background.jpg

There we go, our server is running in the background. But what if we need to stop it? Well, we would first need to find the process ID number, after that we use the kill command to stop it:

kill.jpg

There we go, up to method number 2

Using screen

A remote linux terminal supports multiple vitual screens. This to stop the user from creating multiple sessions. This is done by the "screen" command. For more information :

man screen

We first need to start a virtual screen, therefore we type in "screen". At first glance it will look like the screen has just cleared. But it has not. Now you can start the server and close the terminal.

screen.jpg

When you come back and log in again you can see that the server is still running on a different terminal:

screen3.jpg

with the command

screen -r

you can bring back your server and look at the output:

screen2.jpg

Link to comment

nice guide blokker, but if i may, im going to add some more.

If you have more than 1 server running, the "screen -r" command will bring up a list of the running processes like this:

putty10pw.png

If you want to view a specific server, you will need to do "screen -r [pid]", so in my picture for example, "screen -r 19982" would bring up the first server:

putty27xw.png

But what happens if some cracknut comes onto your server with an exploit panel and crashes it? No more server for anyone until you get it started again? Nope. If you're smart, you would be running a restart script. Mine checks every 10 seconds to see if the server is running, and if its not then it will automatically start it back up again. This basically makes the Shutdown button in MTA:mA act like a restart button.

Also one last command you may find useful is "ps x". This shows you all the running applications on the server:

putty36wv.png

Link to comment
  • 2 months later...

Hello I am having problem even starting the server

Here is what happen

login as: root

[email protected]'s password:

Last login: Sun Jun 12 14:31:05 2005 from ool-4350dd13.dyn.optonline.net

root@host [~]# /mta

-bash: /mta: is a directory

root@host [~]# $ ./MTAServer0.5

-bash: $: command not found

root@host [~]#

Now what do I do I run a linux server :(

the $ command is not found.

Link to comment

root@host [~]# ./MTAServer0.5

-bash: ./MTAServer0.5: No such file or directory

The file is in there.... chmod 777....

I also tried run ./MTAServer0.5

it give me Unable to exec error.

Link to comment
  • 2 months later...
I think that your host you dont give exec rights...

Lol u crazy dude , read what he wrote he is logged in as root , and if a host doesnt give exec right to a root , than that is the suckiest host i seen so dude change ur hoster :lol: if ur not root . to find out what is ur designation type :

whoami on the screen.

Or try to login as superuser , maybe that will let us know if ur really root and owner . if still having problem pm me, i get ur server runnning/

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...