How to save print instructions when starting a program in SLURM?

I am running Python code containing print instructions through SLURM. Usually, when I run Python code directly through "python program.py", print statements appear in the terminal. When I run my program through SLURM, as expected, print statements do not appear in the terminal. How to save print instructions to a file so that I can check them as the program starts? Below is my script message, which I send via "sbatch submit.sh". Note that I have already tried two methods to write the output of either test1.out or test2.out. Please let me know where I am going wrong!

#!/bin/bash

#SBATCH -J mysubmission
#SBATCH -p New
#SBATCH -n 1
#SBATCH -t 23:59:00
#SBATCH -o test1.out

module load gnu python

python program.py > test2.out
+4
source share
2

print Python , , stdout "", stdout.

. question .

- Python -u.

python man:

-u Force stdin, stdout stderr . , , stdin, stdout stderr . , xreadlines(), readlines() ( " sys.stdin" ), . , "sys.stdin.readline()" "1:".

+3

:

python -u program.py > test2.out

test2.out.

0

Source: https://habr.com/ru/post/1611993/


All Articles