Continuous Copying from a directory to another.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Continuous Copying from a directory to another.
# 8  
Old 11-07-2017
You are still ignoring the fact the a file might still be arriving as you copy it, with the result that the copy may not be the entire file.
sorry, I missed your comment about .temp in post 5.

Why not simply modify the process that renames the file to also do the copy.

Last edited by jgt; 11-07-2017 at 05:54 PM..
# 9  
Old 11-08-2017
Quote:
Originally Posted by sadique.manzar
hereis what i am trying:

Code:
#!/bin/sh
DATE=`date +"%d-%m-%Y %H:%M:%S"`
path=/xyz/S1
while true
do
    for  files in `printf "%s\n" $path/*.RTM 
    do
        if [[ -f $files ]] && [[ -s $files ]]
        then
            cp -n $files  /xxx
        else
            echo "file doesn't exist" >/dev/null
        fi    
    done
done

The echo-line doesn't make any sense. You are writing something to the bitbucket? What for? Also, you create a variable DATE, but never use it. Finally, shell scripts which really loop permanently and do file operations continuously, might consume a considerable amount of processing power. You should at least sleep one or two seconds between iterations.

Having said this, rsync might be easier to use:

Code:
rsync --min-size=1 $path/*.RTM /xxx

This obviates the need for the nested for loop and the checking for the file size.
This User Gave Thanks to rovf For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying files to a directory

Hi, I am newbie to unix scripting, need a help in the doubt i have. It is " when files are copied to a directory using cp command, they are arranged by default according to the file name, is there anyway where the files that are copied be arranged with respect to their size, with using the sort... (5 Replies)
Discussion started by: pundalik
5 Replies

2. Shell Programming and Scripting

Copying subdirectories of a directory to some other directory and renaming them

Hi, I am a newbie in shell scripting. I have to copy a particular sub-directory (data) from a large no. of directories (all in the same folder) and paste them to another directory ( /home/hubble/data ) and then rename all the subdirectories (data) as the name of its parent directory. please... (8 Replies)
Discussion started by: sholay
8 Replies

3. Shell Programming and Scripting

Copying files to a directory

Hi I have a few questions. I am trying to copy a file to a directory. I need to copy files that do not end in numbers, for example, into a directory. This is what I tried so far. cp filename directorytowhereIwannacopy but it says it can't copy to a directory. I need to copy many files into one... (2 Replies)
Discussion started by: #moveon
2 Replies

4. Shell Programming and Scripting

Copying files from one directory into another.

Could someone please tell me if there is a command similar to head or tail that can be used on directories. I want to select a given number of files from a directory and copy them into another directory. But I found out I can't use head as it doesn't (or I don't know how yet!) work on directories.... (4 Replies)
Discussion started by: Krush187
4 Replies

5. Shell Programming and Scripting

Copying curent directory

I am trying to write a script that first copies all the directories and files from the current directory into a new Directory. I get and error "Cannot copy directory into itself". That's fine. I don't want it to. What I am worried about is when I give this script to my company (they are using a... (2 Replies)
Discussion started by: Fred Goldman
2 Replies

6. UNIX for Dummies Questions & Answers

Copying one file at a time from one directory to another directory.

Hi All i want to write a script which could copy one file at a time from one directory to another directory. Scenerio: Let's say i have 100 file in a dirctory,so i want to copy one file at a time to another directory with a sleep statement in between that of 30 secs. please help me... (1 Reply)
Discussion started by: Nikhilindurkar
1 Replies

7. UNIX for Dummies Questions & Answers

Copying files from one directory to Other

Hi UNIX Gurus, Could please help me out regarding following situation. I am copying some files from one directory to other directotry using following command. cp /var/tmp/*date*.gz /var/tmp/user/ Problem: Once the copy has completed, I need to check whether all the files (including... (3 Replies)
Discussion started by: satishkeshetty
3 Replies

8. UNIX for Dummies Questions & Answers

Copying with directory structure

Hi, I need to copy a set of directories along with all sub directories and files from one unix box to another. Any ideas? cnfsed (4 Replies)
Discussion started by: Cnfsed
4 Replies

9. UNIX for Dummies Questions & Answers

copying a file from one directory to another

Hi This is my first day in Unix, and I am trying to copy a file called holiday.txt from my D drive into the C drive folder called h like currently i am in D drive, i want to copy my holiday.txt into C\h (C drive, h folder) i am able to copy the file in the same drive, but how to do the... (5 Replies)
Discussion started by: soujanya_srk
5 Replies

10. UNIX for Dummies Questions & Answers

Problems with Copying Directory

Hi, i'm completely new to Unix. I'm trying to copy my "Pictures" folder, and all the folders under it, to a different folder "Photos". So say "Pictures" has a sub folder "2". what happens is "2" is copied to "Photos" like i want it to, but then a sub directory "tmp2" is made which... (3 Replies)
Discussion started by: brudnerx
3 Replies
Login or Register to Ask a Question