Linux – Running python app in the background on linux

background-processlinuxpythonsshterminal

Weird question here, but I'm playing with a python chat server/client combo on my Linux server. Currently, if I do this:

$: cd /path/to/chat/server
$: sudo python ChatServer_Listen.py

This starts the python app run loop and the server listens for incoming TCP connections.

My problem is, if I close my terminal window, the ssh session quits and the python app stops running, and clients can no longer connect. I'd rather not run a terminal instance 24/7 locally. Can I set up this python app as something that can run in the background on Linux? If so, how? Ideally it would be sort of like Apache which just runs as a service.

Thanks for helping me out!

Best Answer

You can use nohup python ChatServer_Listen.py &

nohup will log your program output to nohup.out file.

To stop your program you have to use kill your_pid command.