LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Slightly Off Topic : Concurrent Access to a Text File in a bash script - can I enforce thread safety

[ILUG] Slightly Off Topic : Concurrent Access to a Text File in a bash script - can I enforce thread safety

Eoin Hennessy eoin at sdf.lonestar.org
Fri Jul 13 14:21:30 IST 2007


Perhaps you could use a lock file.. or move to a language with
threading support.

Eoin

On 7/13/07, Oisin Kim <oisinkim at gmail.com> wrote:
> Hi All,
>
> not a linux question, but I know there are some bash experts out there, so
> hope this can be answered by someone.
>
> Basically I have a very simple script, it will generate checksums for some
> files and write the details to a log file, since the number of files is
> small, and the server has a will have a large number of CPUs I'd like to run
> the checksums in parallel.
>
> What concerns me is how I can be sure that writes to the log file are
> "thread safe", so that different processes don't corrupt the entries.
>
> I've not been able to get any process writing to the file to overlap, but
> that was on a limited test of 1000 files, and on my laptop.
>
> Something as simple as this:
>
> for i in *.* do
>     cksum $i >> log.file &
> done
>
> So far I can't get two cksum processes to overlap each other in the log.file,
> but I understand this might be hardware/file numbers.
>
> I googled around and couldn't find something that answered this, so sorry if
> I am asking a dumb question!
>
> Thanks in advance,
> Oisin
> --
> Irish Linux Users' Group mailing list
> About this list : http://mail.linux.ie/mailman/listinfo/ilug
> Who we are : http://www.linux.ie/
> Where we are : http://www.linux.ie/map/
>



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell