-1

I have written some code that I would like to run in the background as it is very time consuming (on the order of hours). I would normally run

python3 program_name.py >> output.log &

However the first steps of the program take user input. Is there a way to take user input and then run in the background if I close the terminal?

magladde
  • 614
  • 5
  • 23
  • 1
    Try this? https://stackoverflow.com/questions/45641094/how-to-accept-input-from-stdin-in-background-while-program-is-running – Devesh Kumar Singh Mar 23 '19 at 12:08
  • 3
    Use [argparse](https://docs.python.org/3.7/library/argparse.html) and pass user input at command line. – SuperShoot Mar 23 '19 at 12:10
  • 1
    Possible duplicate of [How to accept input from stdin in background while program is running](https://stackoverflow.com/questions/45641094/how-to-accept-input-from-stdin-in-background-while-program-is-running) – Alec Mar 23 '19 at 12:11
  • 1
    Take a look at daemonize https://github.com/thesharp/daemonize – geckos Mar 23 '19 at 12:26

1 Answers1

2

You could use something like Tmux and detach and then re-attach when needed.

Tmux

hamish sams
  • 433
  • 4
  • 9