15

I need to make static website. So I connected via ssh to some local server, where I want to make a static website. Then I used python to make it work:

$ python -m http.server 55550

But if I close terminal, then python program is terminated. I want to shut down my computer, but I want to let this process running on that local server, so other people could still access that website.

How can I do this? After that, how should I terminate that process later?

Thanks for any help

jww
  • 97,681
  • 90
  • 411
  • 885
Entity Black
  • 3,401
  • 2
  • 23
  • 38
  • 1
    this is probably better on the superuser, but you should look int making it a daemon (using your os's facilities for do that), but based on the shell prompt you can try `nohup` using something `nohup python -m SimpleHTTPServer 55550` will make that not respond to hup and continue to run if the term proc goes away. – Doon Sep 04 '13 at 13:07

3 Answers3

22

Use the nohup shell builtin:

nohup python -m http.server 55550

To terminate the process, simply kill it using the kill command, just like any other process.

Matt
  • 27,170
  • 6
  • 80
  • 74
user4815162342
  • 141,790
  • 18
  • 296
  • 355
9

you can also launch it in background

python -m http.server 55550 &

then enter

disown

to detach the process to the current term

Matt
  • 27,170
  • 6
  • 80
  • 74
  • 1
    python -m SimpleHTTPServer 55550 & disown it allowed me to enter more commands in that terminal, but it dont work after I exit ssh – Entity Black Sep 04 '13 at 13:16
  • It should as I do it everyday with many others process I launch ;) You may miss something. :/ –  Sep 04 '13 at 13:25
  • 2
    @Windkiller [disown vs nohup](http://www.zzrevi.com/q/answers-difference-between-nohup-disown-and-3886.html) ;) –  Sep 04 '13 at 13:37
  • 1
    Interesting, but problem remains. Once I exit ssh and connection is closed, my proceses die with disown... – Entity Black Sep 04 '13 at 13:56
  • you are sure that before exiting the ssh connection your enter disown just after having enter `python -m SimpleHTTPServer 55550 &` ? –  Sep 04 '13 at 13:58
  • Im very sure. This server isnt mine. Maybe there is some daemon that collects and terminates some kind of processes... ? – Entity Black Sep 04 '13 at 14:16
4
screen
python -m SimpleHTTPServer 55550 &
press ctrl+a, then press d
exit

shutdown your computer
...
start your computer
ssh your server
screen -r
thinker3
  • 12,771
  • 5
  • 30
  • 36