<div dir="ltr">Hi Sean,<div><br></div><div>Thanks for your suggestion!</div><div><br></div><div>Adding the <font face="monospace">-u</font> flag does not seem to have an impact on whether data is buffered. I also tried adding <font face="monospace">stdbuf -o0</font> before the call to <font face="monospace">srun</font>, to no avail. </div><div><br></div><div>Best,</div><div>Maria</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 10, 2021 at 4:30 AM Sean Maxwell <<a href="mailto:stm@case.edu">stm@case.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Maria,</div><div><br></div><div>Have you tried adding the -u flag (specifies unbuffered) to your srun command?</div><div><br></div><div><a href="https://slurm.schedmd.com/srun.html#OPT_unbuffered" target="_blank">https://slurm.schedmd.com/srun.html#OPT_unbuffered</a></div><div><br></div><div>Your description sounds like buffering, so this might help.</div><div><br></div><div>Thanks,</div><div><br></div><div>-Sean</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 9, 2021 at 6:49 PM Maria Semple <<a href="mailto:maria@rstudio.com" target="_blank">maria@rstudio.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello all,<div><br></div><div>I've noticed an odd behaviour with job steps in some Slurm environments. When a script is launched directly as a job, the output is written to file immediately. When the script is launched as a step in a job, output is written in ~30 second chunks. This doesn't happen in all Slurm environments, but if it happens in one, it seems to always happen. For example, on my local development cluster, which is a single node on Ubuntu 18, I don't experience this. On a large Centos 7 based cluster, I do.<br><br>Below is a simple reproducible example:<br><br>loop.sh:</div><div><font face="monospace">#!/bin/bash</font></div><div><font face="monospace">for i in {1..100}</font></div><div><font face="monospace">do</font></div><div><font face="monospace"> echo $i</font></div><div><font face="monospace"> sleep 1</font></div><div><font face="monospace">done</font></div><div><font face="monospace"><br></font></div><div>withsteps.sh:</div><div><font face="monospace">#!/bin/bash</font></div><div><font face="monospace">srun ./loop.sh</font></div><div><div><br></div><div>Then from the command line running <font face="monospace">sbatch loop.sh</font><font face="arial, sans-serif"> followed by </font><font face="monospace">tail -f slurm-<job #>.out</font><font face="arial, sans-serif"> prints the job output in smaller chunks, which appears to be related to file system buffering or the time it takes for the </font><font face="monospace">tail</font><font face="arial, sans-serif"> process to notice that the file has updated. Running </font><font face="monospace">cat</font><font face="arial, sans-serif"> on the file every second shows that the output is in the file immediately after it is emitted by the script.</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">If you run </font><font face="monospace">sbatch withsteps.sh</font><font face="arial, sans-serif"> instead, </font><font face="monospace">tail</font><font face="arial, sans-serif">-ing or repeatedly </font><font face="monospace">cat-</font><font face="arial, sans-serif">ing</font><font face="arial, sans-serif"> the output file will show that the job output is written in a chunk of 30 - 35 lines.</font></div><div><br></div><div>I'm hoping this is something that is possible to work around, potentially related to an OS setting, the way Slurm was compiled, or a Slurm setting.</div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Thanks,<br></div>Maria<br></div></div></div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Thanks,<br></div>Maria<br></div></div>