-2

I am currently hosting a couple servers on my AWS EC2 Ubuntu 14.04 server. By default, the server doesn't have a GUI, but I installed one along with xRDP.

If I run the script from the terminal, it will continuously run until the terminal is closed. But, if I run the script by simply double clicking it, it will run in the background and keep running regardless of whether the terminal window is open.

This is a problem, because with xRDP sessions, when they close, the running windows in that session close as well. I want to be able to start and stop the servers using SSH, instead of having to manually remote desktop in.

I have a way to easily kill the servers: sudo killall -v python2.7, and I can do this via SSH easily. The problem is, I cannot open the scripts for starting each server, because when I do, it runs the server in the terminal instance that is created on my computer. When I close that instance, the server closes as well.

So the basic, TL;DR version is that I want to be able to run a script in the background via ssh. Does anyone have any ideas?

Thanks!

Justin

Schwaitz
  • 473
  • 3
  • 12
  • 1
    You shouldn't be starting your server processes via scripts. You should create them under a proper management system like upstart or systemd. – Daniel Roseman Jul 23 '16 at 06:33
  • 1
    Possible duplicate of [Getting ssh to execute a command in the background on target machine](http://stackoverflow.com/questions/29142/getting-ssh-to-execute-a-command-in-the-background-on-target-machine) – tripleee Jul 23 '16 at 06:58
  • @DanielRoseman The servers are still under development, thus making them unstable. I like to be able to start and restart them as I please. – Schwaitz Jul 23 '16 at 06:59
  • I feel as though they were asking a different question, @tripleee. The answer below was perfect for what I needed! – Schwaitz Jul 23 '16 at 07:01
  • @Schwaitz how is this not an exact duplicate of the linked question? How can you say it is a different question? It is asking exactly the same thing, and the answer you have marked as accepted is even one of the answers to that question as well. – Mark B Jul 23 '16 at 14:25

1 Answers1

0

What I use for things like this is the screen command putting my command in a disconnected screen session. I can connect to it later if I need to.

Skaperen
  • 16
  • 2