Prev: Call for Paper The International Journal of Computer Science (IJCS)
Next: python & perl bigint difference
From: #! /shell/nerd on 11 Mar 2010 14:07 On Mar 3, 7:39 am, Geoff Clare <ge...(a)clare.See-My-Signature.invalid> wrote: > #! /shell/nerd wrote: > >> > > And I have 10 such JVMs in a machine so they all simultaneously try to > >> > > write to this file at one instance. Now I found that Atleast one is > >> > > missed during the simulataneous write at the beginning e.g. JVM08 > >> > > might not be able to get a chance to put it's entry in the file. > >> Before starting any JVM, In it's own process I'm doing printf "JVMXX > >> \n" >> /tmp/out > >> So each JVM writes to the file first & then continues with the start. > > > I'd appreciate if somebody could suggest anything !! > > What shell are you executing that printf in? If it is not a > POSIX-conforming shell then it's possible that it is implementing ">>" > by just seeking to the end of the file instead of setting O_APPEND on > the file descriptor. > > -- > Geoff Clare <netn...(a)gclare.org.uk> I'm using KSH. Is there any way around this. It's really annoying. My script works for say 10 machines but any greater connections it fails while creating the file (using >> /tmp/out).
From: Mark Hobley on 11 Mar 2010 15:08 #! /shell/nerd <vikasera(a)gmail.com> wrote: > I'm using KSH. Is there any way around this. It's really annoying. My > script works for say 10 machines but any greater connections it fails > while creating the file (using >> /tmp/out). You need to secure a unique instance, before writing to the file: http://markhobley.yi.org/shell/howto/nomulti.html Mark. -- Mark Hobley Linux User: #370818 http://markhobley.yi.org/
From: Geoff Clare on 12 Mar 2010 08:40 Mark Hobley wrote: > #! /shell/nerd <vikasera(a)gmail.com> wrote: >> I'm using KSH. Is there any way around this. It's really annoying. My >> script works for say 10 machines but any greater connections it fails >> while creating the file (using >> /tmp/out). > > You need to secure a unique instance, before writing to the file: That shouldn't be necessary with a POSIX-conforming shell. The file should be opened with O_APPEND set, which will ensure that no data is lost. Some possible causes of the problem are: 1. The ksh that the OP is using doesn't set O_APPEND. Maybe clones such as pdksh are like that; I doubt if any "real" ksh is. 2. The OP thinks the printf is being executed by ksh, but actually it is being executed by a different shell. 3. The shell really is setting O_APPEND, and the underlying O/S has a bug. Before resorting to locking, the OP should at least try to find out for sure whether O_APPEND is being set. On most systems he should be able to do that using a tool such as truss or strace. -- Geoff Clare <netnews(a)gclare.org.uk>
First
|
Prev
|
Pages: 1 2 Prev: Call for Paper The International Journal of Computer Science (IJCS) Next: python & perl bigint difference |