title: Parallel writing to a file from multiple processes by using echo
body: <p>I have written a function in our ERP-System which writes a log to a file on the server by simply "echoing" it to the logfile.</p>
  
  <pre><code>echo "SOME LOGDATA" &gt;&gt; /users/erp/log/LOGMSG
  </code></pre>
  
  <p>Every time a user triggers a specific event, the LOG function is called.</p>
  
  <p><strong>What would happen if 2 users trigger the LOG event exactly at the same time?</strong></p>
  
  <p>Does "echo" take care of file locking?
  In my opinion it has to be the linux kernel or the bash who has to takes care, that a file is not written by 2 command line instructions simultaneously.</p>
  
  <p>I wrote a testcase to force this condition (some 1000 LOG calls within one second) and it seems that my thoughts are right but I can not be really sure, that these calls are executed at the same time on the bash.</p>