Friday, October 29, 2021

[SOLVED] How to run python scipt in the background(after user input) even if the terminal is closed

Issue

I have a python script that takes some inputs from the user & then executes the code based on the input. The code takes some time to complete; during this code runtime the user can close the terminal(the code is run from a Linux machine) As soon as the user closes the terminal the script stops as well. I know there are options like nohup but it wouldn't accept any input(where input is required in my script).

How can I fix this?

Requirement is -

  1. Run the script, enter the inputs

  2. Let the code run in the background even if the terminal is closed

  3. Also is there a way to write whatever is being printed in the terminal(during the script runtime) to some file

Solution

Linux's screen tmux served my purpose.



Answered By - Satnau