close

How to run Flask Server in the background

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to run Flask Server in the background in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to run Flask Server in the background?

  1. How to run Flask Server in the background?

    nohup allows to run command/process or shell script that can continue running in the background after you log out from a shell.

  2. run Flask Server in the background

    nohup allows to run command/process or shell script that can continue running in the background after you log out from a shell.

Method 1

Use:

$ sudo nohup python app1c.py > log.txt 2>&1 &

nohup allows to run command/process or shell script that can continue running in the background after you log out from a shell.

> log.txt: it forword the output to this file.

2>&1: move all the stderr to stdout.

The final & allows you to run a command/process in background on the current shell.

Method 2

Install Node package forever 
Then use

forever start -c python your_script.py

to start your script in the background. Later you can use

forever stop your_script.py

to stop the script

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read