Moving Completely Transfered files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Moving Completely Transfered files
# 1  
Old 09-14-2007
Moving Completely Transfered files

I have a driectoty called TEMP on server 1.There is a process running on another server which is pushing files in this directory of server 1.
I want to write a script which will move the files from TEMP directory to TEMP2 directory on server 1 only but make sure that it will only copy those files which have been transferred completley from server 2 i.e. it should not move files from TEMP to TEMP2 which are currently being pushed from server 2 as the data will be corrupted.
How can i know if the file is being accessed in shell script?
# 2  
Old 09-14-2007
Knowing if a file has finished xferring

There may well be much more elegant ways of doing this but I have done this in the dim and distant past by simply looking at the files over a period of time - say one minute - and if the mtime and size have not changed then you can be pretty well sure the transfer has finished.

Possibly a better way would be to identify the process doing the transfer (via its pid via ps) and if/when the process finishes assume the transfer is complete.

*yet* another way would be to get the sending server to transfer a zero length 'flag' file when the transfer has finished. when you see the existance of the flag file you know the transfer has finished.

so

on server2
start send of filename..................send ends (this may take a while)
send finename.flag (0 length - this will take a very short time)

on server1 ensure you remove the flag files as you process the transfered files

Hope this helps
# 3  
Old 09-14-2007
Thanks....I think the first approach is easy one.....what we can do is get filenames and sizes of each file in TEMP directory using ls -ltr command......then sleep for 2 minutes........after 2 minutes get this information again........and move those files which have same size ..........
Can anybody help converting this to sript?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Csh doesn't source init files completely

I have a strange problem with (t)csh since the latest opensuse/tumbleweed upgrade. csh and tcsh don't source the init files completely. They seem to terminate after sourcing the first nested file. They process the code in /etc/csh.cshrc until they find a command like source... (3 Replies)
Discussion started by: heiko123
3 Replies

2. AIX

Moving Hidden files to normal files

I have a bunch of hidden files in a directory in AIX. I would like to move these hidden files as regular files to another directory. Say i have the following files in directory /x .test~1234~567 .report~5678~123 .find~9876~576 i would like to move them to directory /y as test~1234~567... (10 Replies)
Discussion started by: umesh.narain
10 Replies

3. UNIX for Dummies Questions & Answers

Moving Files to VM

Hi guys, i need to test a script on my RedHat which it's mounted on a VirtualBox (oracle VM). So i need to copy a directory with subdirectories, from a remote host to my VM. I'd like to do that within cmd not with program like Filezilla or something like that. Any idea please? (4 Replies)
Discussion started by: Newer
4 Replies

4. UNIX for Dummies Questions & Answers

Moving files..

Selected directories on our system generate alerts when they exceed 60% of the disk space so I have used gzip to make the files smaller on one of the directories in question (AdminServer logs). I want to move these to another directory what is the best way to make this happen? Thanks.. (4 Replies)
Discussion started by: nosuchluck
4 Replies

5. Shell Programming and Scripting

Finding files with wc -l results = 1 then moving the files to another folder

Hi guys can you please help me with a script to find files with one row/1 line of content then move the file to another directory my script below runs but nothing happens to the files....Alternatively Ca I get a script to find the *.csv files with "wc -1" results = 1 then create a list of those... (5 Replies)
Discussion started by: Dj Moi
5 Replies

6. Shell Programming and Scripting

Need help creating a script to FTP files to a server and then delete the files that were transfered.

I am trying to FTP files to a Windows server through my Linux machine. I have setup the file transfer with no problems but am having problem deleting those files from the Linux box. My current non-working solution is below. Any ideas, anyone?? :wall: Please be gentle, I'm fairly new to this... (4 Replies)
Discussion started by: jmalfhs
4 Replies

7. UNIX for Dummies Questions & Answers

Moving Multiple files to destination files

I am running a code like this foreach list ($tmp) mv *_${list}.txt ${chart}_${list}.txt #mv: when moving multiple files, last argument must be a directory mv *_${list}.doc ${chart}_${list}.doc #mv: when moving multiple files, last argument must be a... (3 Replies)
Discussion started by: animesharma
3 Replies

8. Shell Programming and Scripting

moving the files in a.txt files to a different directory

HI All, I am coding a shell script which will pick all the .csv files in a particular directoryand write it in to a .txt file, this .txt file i will use as a source in datastage for processing. now after the processing is done I have to move and archive all the files in the .txt file to a... (5 Replies)
Discussion started by: subhasri_2020
5 Replies

9. Shell Programming and Scripting

sftp + expect: disconnection & restart removes already transfered data.

I have an ftp statement that when it restarts, it will write over the top of the file at the other end, rather than append to the file part sitting at the destination. This is a problem because the flaky connection fails so regularly that the 2GB file I try to transfer will never complete. ... (2 Replies)
Discussion started by: rupert160
2 Replies

10. Shell Programming and Scripting

moving between vi files

would any one please tell me which keys we used between opened vi files backward and forward Thanks Ayah (2 Replies)
Discussion started by: aya_r
2 Replies
Login or Register to Ask a Question