0

I have a python script script.py

from time import sleep
    for i  in range(30):
    print(i)
    sleep(1)

I wrap this script into bash script script.sh

#!/bin/bash
python3 python_test.py

I want to run the bash script with nohup and redirect the output to output.out. Thus I run the linux command:

nohup bash script.sh > output.out &

However, the output is redirected to output.out only when the python script 'script.py' ends, not in the online manner. Thus the question.

Question. How to redirect the output to output.out into online manner?

Fallen Apart
  • 723
  • 8
  • 20
  • 2
    Possible duplicate of [Telling nohup to write output in real-time](https://stackoverflow.com/questions/28235928/telling-nohup-to-write-output-in-real-time) – El Ruso Oct 12 '19 at 12:55
  • Yes, this is what I needed. `nohup unbuffer bash script.sh > output.out &` does the job. Thanks (; – Fallen Apart Oct 12 '19 at 13:03
  • no bash scripting is needed , put `#!/usr/bin/env python3` shebang into your python script. – VPfB Oct 12 '19 at 14:13

0 Answers0