$ python program.py &
OR
$ python program.py Ctrl+Z $ bg
Make sure there aren't any terminal user input (raw_input, input, etc) when doing so. Otherwise it'll automatically stop when putting it in the background.
Offline
Magnie wrote:
Code:
$ python program.py &OR
Code:
$ python program.py Ctrl+Z $ bgMake sure there aren't any terminal user input (raw_input, input, etc) when doing so. Otherwise it'll automatically stop when putting it in the background.
Thanks! I'm currently waiting for the ubuntu install to finish, but after that, I'll turn it right on.
Offline
OK, that works while I have SSH open, but stops when I close it. Any other ideas?
EDIT: that only happens with the bg command. Thanks, Magnie!
EDIT: EDIT: nvm.
Last edited by GeonoTRON2000 (2012-08-28 23:18:26)
Offline
Hmm... So.. is it working or not? The host server does need to always be on. If you are running the server on your laptop, it'll (probably) shut down whenever you close the lid.
Cause those are the two ways to put them in the background. The only other way is with 'screen' or something similar to it.
Offline
Magnie wrote:
Hmm... So.. is it working or not? The host server does need to always be on. If you are running the server on your laptop, it'll (probably) shut down whenever you close the lid.
Cause those are the two ways to put them in the background. The only other way is with 'screen' or something similar to it.
My VPS is hosting the server while I have SSH open on my laptop, but then stopping when I close SSH.
Therefore, it is not working.
How might I add:
python 20chatpy/server.py &
to the startup program list?
Last edited by GeonoTRON2000 (2012-08-29 10:12:45)
Offline
It's not exactly easy, I haven't even figured it out.
Offline
Use "screen", as Magnie suggests -- it gives you a persistent terminal.
Run the screen command, which should give you a bash prompt. Run your Python program from there (no "&" necessary). You should then be able to disconnect SSH (or press Ctrl+A, D) and have the script continue running in the background.
You can then reconnect later using "screen -r", and it'll resume the same bash prompt -- you can kill Python with Ctrl+C, or whatever.
Of course, if you want to have it run as a service, that's a whole different thing...
Last edited by blob8108 (2012-08-29 12:07:30)
Offline
blob8108 wrote:
Use "screen", as Magnie suggests -- it gives you a persistent terminal.
Run the screen command, which should give you a bash prompt. Run your Python program from there (no "&" necessary). You should then be able to disconnect SSH (or press Ctrl+A, D) and have the script continue running in the background.
You can then reconnect later using "screen -r", and it'll resume the same bash prompt -- you can kill Python with Ctrl+C, or whatever.
Of course, if you want to have it run as a service, that's a whole different thing...
![]()
The screen command works until I decide to reboot the machine...
Would I just copy that script to start this as a service?
Offline
GeonoTRON2000 wrote:
blob8108 wrote:
...if you want to have it run as a service, that's a whole different thing...
The screen command works until I decide to reboot the machine...
Ah, okay. I see what you want now.
Would I just copy that script to start this as a service?
Something like that -- have a look at his post (#4 on that page). You need to at least modify the "PROG" variables at the top. I haven't tried it, so I have no idea
Offline