Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simultaneous execution of a "single minded" executable...

Status
Not open for further replies.

Dprell

Programmer
Nov 12, 2004
3
US
Here is my situation:

I have a VBScript that, among many other things, is creating a batch file that contains an execution of gtar to uncompress a tar file.

This VBScript is executed when a certain file is present in a directory. Execution is not the problem unless this script is kicked off simultaneously at the same time by two different automating tasks.

The automating task is looking for a specific file respective to a client in their directory. There are approximately 100 tasks that look for files in their respective client's directories that execute at random times throughout every day.

Once in a great blue moon, 2 tasks will kick off at the exact same time, which they will then both go through their script and will try to use gtar at the same time to uncompress their respective files.

Gtar does not agree with simultaneous execution and therefore procedes to uncompress only one of the files, or possibly both at the same time, and in doing so, "mish-moshes" the uncompressed files in one or both of the client's directories, thus causing a mess for me to clean up.

I have tried to implement a randomizing equation(s) to give me a value to use for a sleep command to offset the execution of gtar but there is still a remote chance that they will still execute the script at the same time, giving the same random number and still executing gtar at the same time.

I have tried Winzip's command line interface but it does not support uncompressing .tgz files.

The version of gtar I am utilizing is 1.12. I looked for a windows exe of 1.14, but was unable to find it.

The machine is a Dual P4 Xeon 3.06, 4 GB Ram, plenty o' hard drive space and running on Win 2k3 that is up to date.

Question:
Is there another way to:
- Uncompress each of the files automatically using third party software other than gtar?
- another course of action I should be looking at?

Any help is greatly appreciated.
 
What you can do it write a signature file before untarring (holding onto a handle for the signature file), and when you're done you delete the signature file. You'd check to see if the signature file got created without error - if you weren't able to create it, that meant that another process was holding onto it's handle to the file, and you know that another process was in the middle of running gtar.

By holding onto the handle, should gtar die, or the vbscript die, the handle will be released by the OS, and the next time another script runs it will overwrite the file without any errors.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Hi Chiph,

Thanks for responding!

If the file was in the process of using gtar, this "lockfile" would work just fine to keep the other process from processing at the same time.

But....

The problem comes in when 2 files, are trying to use gtar at the same time. They both would try to create that signature file, but they cannot do that at the same time, and in creating that lockfile at the same time, they would probably both error out. I am going to code an example up and see what the results would be as I am interested to know the results. Will post results for all to see as well.

Thanks Chiph!
 
Which is worse? Having one fail, or have them both run, with the results intermingled?

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
There are 2 things I don't understand.
1. Why can you use logic (not really code) as presented below?
2. Why is this thread in an API forum?

Brian

<code>
if lockfile does not exist
make lockfile
endif

if lockfile is not available
loop until timeout setting or file is available
sleep(100)
end loop
endif

if didn't timeout
lock lockfile
do stuff
unlock lockfile
endif

carry on
</code>
 
Thank you for the response, Brian.

I have solved this problem by going with another 32 bit compressing application and adding in some lockfile and waiting sequence logic.

I was not sure where to put this problem so I put it in here trusting a moderator to move where appropriate.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top