# How to flush stdout

**URL:** <https://discourse.julialang.org/t/how-to-flush-stdout/10146>\
**Category:** General Usage\
**Created:** [April 4, 2018, 1:41am UTC](https://discourse.julialang.org/t/how-to-flush-stdout/10146 "2018-04-04T01:41:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [April 4, 2018, 1:41am UTC](https://discourse.julialang.org/t/how-to-flush-stdout/10146/1 "2018-04-04T01:41:59Z")

</div>

I have a Julia script that has a bunch of `println` statements interleaved some heavy computation functions. I typically run such scripts, redirect to a file, and then do `tail -f` to see what’s going on. It appears that the output is buffered. I tried to make it flush but it doesn’t work… What’s the right way to do this?

My logging function:

```julia
log(x...) = println(now(), " ", join(x, " ")...); flush(STDOUT)

```

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [April 4, 2018, 4:45am UTC](https://discourse.julialang.org/t/how-to-flush-stdout/10146/3 "2018-04-04T04:45:11Z")

</div>

> [@tk3369](#):
>
> ```julia
> log(x...) = println(now(), " ", join(x, " ")...); flush(STDOUT)
> 
> ```

This definition doesn’t do what you probably want it to do. It’s equivalent to this:

```julia
log(x...) = println(now(), " ", join(x, " ")...)

flush(STDOUT)

```

You probably want this:

```julia
function log(x...)
    println(now(), " ", join(x, " ")...)
    flush(STDOUT)
end

```

---

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [April 4, 2018, 4:54am UTC](https://discourse.julialang.org/t/how-to-flush-stdout/10146/4 "2018-04-04T04:54:05Z")

</div>

Thanks for correcting my sloppiness 🙂

---

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [December 8, 2020, 5:29pm UTC](https://discourse.julialang.org/t/how-to-flush-stdout/10146/5 "2020-12-08T17:29:48Z")

</div>

Now the solution is:

```julia
flush(stdout)

```

(with lowercase letters)
