top of page
Search

Friday DevOps #2: how long command will sleep?

Writer's picture: Alexey HaritonAlexey Hariton


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

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.



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.


Send this riddle to your colleagues, and Happy Friday!

7 views0 comments

Recent Posts

See All

Kommentare


Subscribe For Our News

Thanks for submitting!

+971581506254

  • dev.to
  • Medium
  • X
  • LinkedIn

©2024 by DevOps Pass AI

bottom of page