Sponsored Content
Full Discussion: Alternative to cp command
Top Forums UNIX for Beginners Questions & Answers Alternative to cp command Post 303018502 by hicksd8 on Friday 8th of June 2018 03:35:49 AM
Old 06-08-2018
I think that I get the question as you've described it quite clearly. Different people will have different solutions but this is what I would do.

(Obviously, if the (original) copy takes several hours then users could be modifying files during that time so you need somehow to cope with that.)

Do the first copy using find piped to cpio and create a timestamp of the event:

Code:
# cd <source directory>
# date > timenow
# find . -depth -print | cpio -puvdm <destination directory>
# mv timenow timelastcopy

NOTE: The <destination directory> MUST already exist before the command is run otherwise it will fail, so create it manually if need be.

After the first copy, select only files that have changed since the last copy by using the -newer switch on find:

Code:
# cd <source directory>
# date > timenow
# find . -newer timelastcopy -depth -print | cpio -puvdm <destination directory>
# rm timelastcopy
# mv timenow timelastcopy

Note that we create the timestamp (timenow) before we start to copy because users might modify files whilst the copy is executing.

This way files that have not changed since before the very start of the last copy will not be copied again. The incremental copies will therefore be much quicker than a full copy. If the job fails to complete then the timelastcopy will not get updated so these files will get selected again on the next run.

Hope that helps and I hope I've explained that clear enough. If not, post back your questions.

Last edited by hicksd8; 06-08-2018 at 12:59 PM..
This User Gave Thanks to hicksd8 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

an alternative of sed command..--imp

Hi Is there a better alternative to sed command.. or any command as an alternate to sed. Thanks!! (3 Replies)
Discussion started by: aixjadoo
3 Replies

2. UNIX for Dummies Questions & Answers

alternative for head command

Hi friends,I am new to unix and this is really a dummy question.but please help me out. How to simulate head command without using head command??? also tail command too,also more command. it is given as a homework to do....please tell me how to do (2 Replies)
Discussion started by: nikhilneela
2 Replies

3. Shell Programming and Scripting

Any alternative of sar command

Hi all, I am using linux box ...i dont find the manual entry of sar command through man sar ...it is in unix not in linux although i have to check the cpu utilization and paging...any alternative of sar command.. Thanks Vijay Sahu (1 Reply)
Discussion started by: vijays3
1 Replies

4. Homework & Coursework Questions

locate command alternative,,

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! Ok, Im back with another small problem. I created a script (the one posted in the last thread). After some help from some members here all is good. The problem is I made it... (4 Replies)
Discussion started by: ozman911
4 Replies

5. Shell Programming and Scripting

Alternative script for LFTP command

Hi, I was looking for a command which would help sending files parallely to remote server , and lftp is the closest option I could got. Unfortunately when I checked the AIX machine I work on does not has lftp installed. Is there any alternative perl script (or something like that) which I can... (1 Reply)
Discussion started by: vinay4889
1 Replies

6. AIX

Alternative command for topas

hi, I need alternative command for topas to check cpu %, i tried with ps but their is lot of diffference between the outputs of two commands... Thanks (3 Replies)
Discussion started by: sumanthupar
3 Replies

7. Shell Programming and Scripting

Maxdepth command not working in AIX.Need alternative solution for this command

Hi All, I am trying to select 30 days older files under current directory ,but not from subdirectory using below command. find <Dir> -type f -mtime + 30 This command selecting all the files from current directory and also from sub directory . I read some documention through internet ,... (1 Reply)
Discussion started by: kommineni
1 Replies

8. Shell Programming and Scripting

Alternative command to grep -w option

Hi All, We have few scripts where we are using grep -w option to do exact matching of the pattern. This works fine on most of our servers. But I have encounter a very old HP-UX System(HP-UX B.11.00) where grep -w option is not available. This is causing my scripts to fail. I need to change... (7 Replies)
Discussion started by: veeresh_15
7 Replies

9. Shell Programming and Scripting

Alternative command/method to curl

is there a different way to do the following: curl -k -H "Content-Type:application/json" -X POST -d'{"api_token": "33blah526c-6bla71-441b-491b-0blahca08"}' https://10.10.10.10/api/1.4/auth/session -c /tmp/myhost01.myhost.com im seeking to use a different method because i'm running into TLS... (1 Reply)
Discussion started by: SkySmart
1 Replies

10. UNIX for Beginners Questions & Answers

Alternative to join command

Ubuntu, Bash 4.3.48 Hi, I have 2 files and I want to join them (line by line if the start of the lines is the same, like a ID) INPUT FILE 1 (tab delimited) aa_12_12_v_c aaa,asf,afgas,eg bb_12_43_a_d dad,ada,adaf,afa cc_56_75_d_f asd,thh,ert,rtertet INPUT FILE 2 (tab delimited)... (4 Replies)
Discussion started by: echo manolis
4 Replies
cpio(4) 						     Kernel Interfaces Manual							   cpio(4)

NAME
cpio - format of cpio archive DESCRIPTION
The header structure, when the option of is not used (see cpio(1)), is: When the option is used, the header information is described by: Longtime and Longfile are equivalent to and respectively. The contents of each file are recorded together with other items describing the file. Every instance of contains the constant 070707 (octal). The items through have meanings explained in stat(2). The length of the null-terminated path name including the null byte, is given by The last record of the archive always contains the name Directories and the trailer are recorded with equal to zero. It will not always be the case that and correspond to the results of but the values are always sufficient to tell whether two files in the archive are linked to each other. When a device special file is archived by HP-UX (using the option), contains a magic constant which is dependent upon the implementation doing the writing. flags the device file as an HP-UX 32-bit device specifier, and contains the 32-bit device specifier (see stat(2)). If the option is not present, special files are not archived or restored. Non-HPUX device special files are never restored. SEE ALSO
cpio(1), find(1), stat(2). STANDARDS CONFORMANCE
cpio(4)
All times are GMT -4. The time now is 04:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy