sselva has asked for the wisdom of the Perl Monks concerning the following question:
Need your help .
I am facing problem when creating a directory using mkdir command in perl .
we have jobs to create directory on daily basis with date stamp and place some files in it based on some condition , so when new day begins our script will create a directory with the current date stamp .
( for example direcotry name looks like" /<dir>/<dir1>/2011-04-02 " )
Issue is when we ran the same script twice at same time on new day , say like both scripts are started around Apr 2 00:01:31 UTC , one job got failed with reason " Cannot create directory".
i used unless ( -d $dir ) { } option to check the presence of the directory , but its not working in this case .
next jobs ran fine because of the " unless ( -d $dir ) { } " conditions , but the (two same jobs at same time ) jobs which are trying to create the file is giving the problem .
is there any other option to avoid this . Please help me on this .
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Directory creation in Perl using mkdir
by moritz (Cardinal) on Apr 04, 2011 at 08:02 UTC | |
by rovf (Priest) on Apr 04, 2011 at 09:44 UTC | |
by moritz (Cardinal) on Apr 04, 2011 at 10:28 UTC | |
|
Re: Directory creation in Perl using mkdir
by lancer (Scribe) on Apr 04, 2011 at 08:03 UTC | |
by cdarke (Prior) on Apr 04, 2011 at 11:48 UTC | |
by lancer (Scribe) on Apr 04, 2011 at 13:24 UTC | |
by cdarke (Prior) on Apr 04, 2011 at 14:16 UTC |