Home > Mobile >  How to capture the output of a Julia script while the script is running in a shell?
How to capture the output of a Julia script while the script is running in a shell?

Time:11-16

I can capture the output of a julia script in the shell with the > operator, for example:

$ julia script.jl > output.txt

However, it seems that the file is only written to after the julia script finished. For example, if script.jl contains the following code:

println("Hello world!)
sleep(10)

then output.txt is created immediately, but the Hello world! appears in the file only after 10 seconds.

Is there a way to immediately write the Julia output to the file as soon as each command is executed and not wait for the script to finish?

CodePudding user response:

println("Hello world!")
flush(stdout)
sleep(10)

So the output isn't buffered.

CodePudding user response:

For instance by

stdbuf -o0 julia script.jl > output.txt
  • Related