DevOps Fun #2: how long command will sleep?

?

In previous aticle: If you’re cool enough to watch video in console?

Recently saw article on one LinedIn channel explaining Linux shell pipes and again saw the same mistake – 99% engineers doesn’t know how pipes actually works!

Absolutely sure you will be “not absolutely sure” how long that command sleep:

sleep 5 | sleep 5 | sleep 5 | sleep 5
Enter fullscreen mode
Exit fullscreen mode

You may “suspect” that it will be 20 seconds, but it’s not true.

It’s surprising people, that ALL commands in pipe running simultaneously! And command will sleep 5 secs.

You can check it with ps -ef | grep slee[p] while sleep is running.

terminal

That’s the reason why you see intermediate result when grepping large file and not waiting for command to finish, in case of sequential run of commands in pipe.

Support Us, Contact Us

Give us a start, we’re kitties ;)

If you like this post, support us, download, try and give us feedback!

Give us a star 🌟 on GitHub or join our community on Slack.


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Martins ad network.