Either cp with the '-p' ("preserve") option, or mv. Both should preserve the modification and access time and permission bits. For ACLs that should be preserved see the man page of your OS.
In addition, look into the -p flag in both tar and scp (if your remote location has ssh running); it's fairly standard among utils, but these are my friends. Also, make sure that you're not bound to a different umask on the new location...if it differs, and you can't reset it as needed, you might be restricted to only what's available to the next machine.
a) mv doesn't have a -p option
b) did you read the man page for cp?
Quote:
If dest_file was created, its file permission bits shall be changed (if necessary) to be the same as those of source_file, modified by the file creation mask of the user if the -p option was not specified.
That means you umask and other properties only apply if you don't specify '-p'.
mv is ok, but if you get some sort of error halfway through it can be difficult to recover.
one of the fastest Ive found is (from source dir):
It uses two processes, so they can be prioritized by the O/S (one for reading, one for writing) but it still moves the data through a pipe which just replicates data in memory and thus is not the most efficient.
scp will encrypt/decrypt and so put unnecessary load on the cpu.
cp -pr on machines like Solaris is pretty fast because it mmaps the files which means there is no duplication of the file data in memory - it is simply tagged by the o/s to be written directly to disk, so should be the most efficient. However if it isnt multithreaded it will waste time waiting for I/O.
I would personally do some tests of all of the above on your O/S using the unix "time" and see which one wins (dont just measure the real time but the system/cpu time as well)
Hi,
I have multiple files that read:
Asa.txt
Bad.txt
Gnu.txt
And I want to rename them using awk to
Asa_ddmmyytt.txt and so on
...
If there is a single command or more efficient executable please share!
Thanks! (4 Replies)
I have created this script
#!/bin/sh
FILES=/data/log/access_*.log
for f in $FILES
do
echo "Processing $f file"
cat $f | awk '{print $1}' | sort | uniq -c | sort -n | tail
done
It produces this output
Processing /data/log/access_abc.log file
114 1.1.1.1
167 2.2.2.2
... (38 Replies)
Hi Folks,
Need a clarification on files with date and time stamp.
Here is my requirement. There is a file created everyday with the following format "file.txt.YYYYMMDDHHMMSS".
Now i need to check for this file and if it is available then i need to do some task to the file.
I tried... (6 Replies)
Hi,
I need help to read file in a directory on basis of time stamp.
e.g. If file access in last 2 minutes it should not be copy to remote directory.
Below is my script.
+++++++++++++++++++++++++
#!/bin/ksh
DATE=`date +"%Y-%m-%d_%H%M"`
SEPARATER=" "
exec < out_interfaces.cfg... (1 Reply)
Hello Friends
I am facing a weird problem :confused:, we receive thousands of files in my system on a daily basis, access time stamp on some of the files are being updated as old time stamp like 1968-01-19, Could some one help me what could be causing this? so that i can narrow down the problem... (4 Replies)
Hi all,
I've already tired to try to solved this problem. Also search in Internet didn't find anything solution
I have a directory like this :
# pwd
/opt/projects/juventini
# ls -al | more
total 3627460
drwxr-xr-x 2 app apps 12472320 Sep 24 14:59 .
drwxr-xr-x 11 app apps 4096 Jun... (8 Replies)
I'm a novice at unix and need it more and more to do my work.
I seem running into problems getting this script "attempt" to work:
I need to copy all files in a directory, which is containing 22000 files, into a directory one level up. There a tool monitors the content of the dir and processes... (2 Replies)
I copied a file from one host to another using sftp. But after copying the time stamp is not updating . Even though I checked the permission, it looks good. I copied the same file to some temporary location, there it updating the time stamp. Anyone have any idea on this (6 Replies)
All,
I am new to unix and i have the following requirement.
I have file(s) landing into input directory with timestamp, first i want to copy all these files into seperate directory then i want to rename these files without timestamp and also remove header,trailer from that file..
Could... (35 Replies)
Hi Everyone,
I want to delete some files in a path based on the time stamp of the file that is i want to delete the file once in a month.
Can any one help me on this?
Thanks in advance (2 Replies)