0

I have a simple run.sh script:

#!/bin/bash
python print.py

Where print.py is just:

print("just")
print("print")

I submit on a cluster with command where I request one CPU and 1 minute of wall time:

sbatch -c 1 -t 1 run.sh

And everyting works fine and I see the expected output in a slurm log file. But if I add time module nothing works:

import time
print("just")
print("print")
time.sleep(10000)

In a log file a see only this message without any prints:

slurmstepd: error: *** JOB 378186 ON cn-011 CANCELLED AT 2021-10-05T20:15:28 DUE TO TIME LIMIT *** 

How can I handle this problem? I expect that I will see such log file:

just 
print
slurmstepd: error: *** JOB 378186 ON cn-011 CANCELLED AT 2021-10-05T20:15:28 DUE TO TIME LIMIT ***
Kenenbek Arzymatov
  • 7,359
  • 16
  • 49
  • 97
  • 1
    Excerpt from this answer: https://stackoverflow.com/questions/33178514/how-do-i-save-print-statements-when-running-a-program-in-slurm By default, `print` in Python is buffered, meaning that it does not write to files or stdout immediately, and needs to be 'flushed' to force the writing to stdout immediately. – Ghoti Oct 05 '21 at 17:27

0 Answers0