Saturday, October 29, 2022

[SOLVED] Run flask application on linux server with nohup

Issue

I am trying to run my flask application on my linux server using nohup , but each time i run my flask application with nohup , my server will require me to kill with cntrl + c in order for me to do other things

assuming i have 2 file in my server path(home/app/)

  1. flask_app.py [ which is my flask application ]
  2. flk.sh

inside my run.sh i have included

nohup python /home/app/flask_app.py

when i run my shell script in my server which is sh flk.sh

my system will hang as per shown in below image if i dont exit it as its running and all activity will go inside nohup.out enter image description here

how can i run nohup on my flask application without me having to use cntrl + c to exit to run other commands.


Solution

You usually want to use nohup command arg1 arg2 &. You're just missing the ampersand.

Briefly, nohup prevents the OS from killing your job, & sends the job in the background, so it isn't tied to your current shell.



Answered By - Quoding
Answer Checked By - Mary Flores (WPSolving Volunteer)