K
kaeli
Hi all,
I've got a shell script (ksh) that does some file copying and deleting.
I'm running into some problems with it that I'm wondering if I can
solve. Since I plan on re-writing it with java (1.4), I figure I might
as well do it right this time.
Here's the drill:
Cron runs this code every 5 minutes.
Program looks on one machine, uses ssh to copy a file to another
machine, changes the filename, the owner and permissions (chmod), and
then deletes the file from the source machine.
Sounds simple enough...
Problems:
Large files (we're talking gigabytes) take more than 5 minutes to copy.
Something is causing the file to be deleted before it has finished
copying. We lose the whole file, as it doesn't show up on either
machine.
Program gets called again while an instance is running, so it tries to
copy files that are currently being copied.
I was going to solve this with the usual .running type fix, but we
really need the program to actually run every 5 minutes (more than one
instance will be needed). If an instance is already copying the file,
the file should just be ignored. The file should not be deleted if the
copy hasn't finished.
Does anyone know of any system stuff I should be looking at for java?
Specifically, Unix Solaris interface so I can tell if a file is in use?
Also, how can I make sure that the copy was finished before deleting the
source? I expected the script to wait for the copy to finish before
deleting, but it appears that it is not doing that. Should I use threads
for this?
Thanks for any ideas, input, etc...
--
I've got a shell script (ksh) that does some file copying and deleting.
I'm running into some problems with it that I'm wondering if I can
solve. Since I plan on re-writing it with java (1.4), I figure I might
as well do it right this time.
Here's the drill:
Cron runs this code every 5 minutes.
Program looks on one machine, uses ssh to copy a file to another
machine, changes the filename, the owner and permissions (chmod), and
then deletes the file from the source machine.
Sounds simple enough...
Problems:
Large files (we're talking gigabytes) take more than 5 minutes to copy.
Something is causing the file to be deleted before it has finished
copying. We lose the whole file, as it doesn't show up on either
machine.
Program gets called again while an instance is running, so it tries to
copy files that are currently being copied.
I was going to solve this with the usual .running type fix, but we
really need the program to actually run every 5 minutes (more than one
instance will be needed). If an instance is already copying the file,
the file should just be ignored. The file should not be deleted if the
copy hasn't finished.
Does anyone know of any system stuff I should be looking at for java?
Specifically, Unix Solaris interface so I can tell if a file is in use?
Also, how can I make sure that the copy was finished before deleting the
source? I expected the script to wait for the copy to finish before
deleting, but it appears that it is not doing that. Should I use threads
for this?
Thanks for any ideas, input, etc...
--