Perhaps you could use a lock file.. or move to a language with
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 &
>> 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,
> 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/>
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!