Currently, I have two servers running on an EC2
instance (MongoDB
and bottlepy
). Everything works when I SSHed to the instance and started those two servers. However, when I closed the SSH session (the instance is still running), I lost those two servers. Is there a way to keep the server running after logging out? I am using Bitvise Tunnelier
on Windows 7.
The instance I am using is Ubuntu Server 12.04.3 LTS.
相关问题
- JQ: Select when attribute value exists in a bash a
- JavaScript File Transfer SSH
- How to upgrade/install Upstart deamon version 1.5
- Why does this bash script work at console but fail
- Connecting to Windows Server Service Bus on AWS
相关文章
- Check if directory exists on remote machine with s
- Git Clone Fails: Server Certificate Verification F
- I cannot locate production log files on Elastic Be
- Test if File/Dir exists over SSH/Sudo in Python/Ba
- Can't access AWS CodeCommit with SSH
- AWS - Configuring access to EC2 instance from Bean
- Error: “The security token included in the request
- Ansible Timeout (12s) waiting for privilege escala
It would be nice if you provided more info about your environment but assuming it's Ubuntu Linux you can start the services in the background or as daemons.
(Use nohup if you want are in a ssh session and want to prevent it from closing file descriptors)
You can also run your bottle.py app using Apache mod_wsgi. (Running under the apache service) More info here: http://bottlepy.org/docs/dev/deployment.html
Hope this helps.
Addition: (your process still runs after you exit the ssh session)
Take this example
time.py
Then run:
Then ssh back to the server
Process still running (notice with no tty)
For those landing here from a google search, I would like to add tmux as another option. tmux is widely used for this purpose, and is preinstalled on new Ubuntu EC2 instances.
Managing a single session
Here is a great answer by Hamish Downer given to a similar question over at askubuntu.com:
Managing multiple sessions
This can be useful if you need to run several processes in the background simultaneously. To do this effectively, each session will be given a name.
Start (and connect to) a new named session:
Detach from any session as described above: Ctrl+B, D.
List all active sessions:
Connect to a named session:
To kill/stop a session, you have two options. One option is to enter the
exit
command while connected to the session you want to kill. Another option is by using the command:You will want the started services to disconnect from the controlling terminal. I would suggest you use
nohup
to do that, e.g.you may need to put an
&
in there (in the quotes) to run it in the background.As others have commented, if you run proper init scripts to start/stop services (or ubuntu's
service
command), you should not see this issue.If you don't want to run some process as a service (or via an apache module) you can (like I do for using IRC) use gnome-screen Install screen http://hostmar.co/software-small.
screen
keeps running on your server even if you close the connection - and thus every process you started within will keep running too.