On Thu, Oct 15, 2009 at 2:25 PM, Kenneth Gonsalves
<[email protected]>wrote:

> I need to run a python server on my remote box. At present I do:
>
> python myserver.py &
>
> my question is: If I log out from the server, will the script keep running?
> or
> will it die as soon as I leave. Experiments on the laptop seem to indicate
> that it will keep running even if I log out.
>
> I can also do
> screen python myserver.py &  <--- this will work even if I log out. How
> about
> the first one. Or is there some other way (script in /etc/init.d/ for
> example
> to do this elegantly?)
>


Running in the screen is the safest and reliable way to keep running a
script after we logout. Steps are:

(i) type "screen" -- this will create a new screen and you'll be inside the
screen.
(ii) python myserver.py (while you're inside the screen)
(iii) Ctrl + A + d -- will take you out of the screen -detaches screen (but
the screen keeps running and also your script)
(iv) Now, you can logout of the server. Once you return, or anytime you need
to "view" the python process running, you need to RESUME the screen that is
detatched. You can do this by issuing : screen -ls (will list out all the
running screen's PID)
                  screen -x #PID of screen to resume


Note: You can do lot more than just running a single process in the screen.
"man screen" can explore those.


-- 
Thanks,
Vanniarajan
_______________________________________________
To unsubscribe, email [email protected] with 
"unsubscribe <password> <address>"
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to