retain create/mod date and time of files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting retain create/mod date and time of files
# 1  
Old 06-15-2005
retain create/mod date and time of files

Hi,

I have a requirement by which I need to take a snapshot of a certain directory of a certain types of files into a target directory within the same server (HP-UX 9000).
The problem is that the files created in the target directory has the date and time of when the files were copied over.
How do I maintain the date and time the files were modified/created in the source directory. Is there any commands/utilities that will enable this preservation. Anys suggestions/ideas are greatly appreciated. thanks.

Jerardfjay
# 2  
Old 06-15-2005
I don't know about hpux, but gnu cp has the -a option that does what you want.
Generally tar is available though, so you could do something like

(cd src/dir && tar c -p .) | (cd dst/dir && tar x -p)

You can search for more tar examples at http://www.pixelbeat.org/cmdline.html
# 3  
Old 06-15-2005
processing files an hour before

hi

I guess you can use "find" command with -newer or -mtime option for getting those files. refer man pages for detailes about this command.
# 4  
Old 06-15-2005
as far as I know --- the copy utilities generally have a "preserve" option to preserve file attributes ... do a man lookup on cp, tar, cpio, etc. ...

Code:
cp -p sourcefile newfile
tar cfp - source | (cd $destdir; tar xfp -)

# 5  
Old 06-15-2005
Yes it's just the -a option. That preserves ALL attributes. Permissions, ownership, creation time, modification time etc etc etc....

It's what you use for backups Smilie
# 6  
Old 06-15-2005
thank you all for your input. I shall use one of the above. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing files by date/time

I am trying to compare identically named files in different directories and replace a file only with a newer version. Is there a way of doing this? TIA (4 Replies)
Discussion started by: wbport
4 Replies

2. Shell Programming and Scripting

Files with date and time stamp

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)
Discussion started by: jayadanabalan
6 Replies

3. Shell Programming and Scripting

How to catch date and time from log files?

Hi, Appli.log files contain the below data which updates continuously ================================================== =============== Tuple Created OrderEntry|66|39.0|ADML.L|16.89|GBP||GFD|000002889 41ORLO1|GB00B02J6398|80|XLON|UHORIZON|null|2011-05-09... (11 Replies)
Discussion started by: pspriyanka
11 Replies

4. Shell Programming and Scripting

How to find the create time of a file if current date is in next month

Hi All, I want to find the time diffrence between currnt time and "abc.txt" file create time. I have solve that but if the abc.txt file created last month then is there any process to find the difftent? Exp: Create time of abc.txt is "Apr 14 06:48" and currect date is "May 17 23:47".... (1 Reply)
Discussion started by: priyankak
1 Replies

5. Shell Programming and Scripting

Need help in changing Mod time of a file

I have a file called MasterRECEIVEFranScript. I need to change its modified time to Sep 20 09:34 2008 For this i have tried a command ,but no success touch -m -t 1222079885 MasterRECEIVEFranScript ------------------------------------------------------------- Plz help me in this ? ... (6 Replies)
Discussion started by: ali560045
6 Replies

6. UNIX for Dummies Questions & Answers

Create a list of files that were modified after a given date.

Hello Mates! I'm kinda new to unix and need to a solve a problem. Input: date Situation: With the given date I need to find a list of all such files starting from a given path that were modified after the given date. I experimented with the "find" with "-newer" but did not quite get it... (4 Replies)
Discussion started by: rkka
4 Replies

7. UNIX for Dummies Questions & Answers

List files with date and time stamps only

Hi there, I'm using terminal on mac and using the ls -l command to list all the files in a directory. However, I only want to display the date and time stamp of each file rather than permissions, owner, group etc... Is this possible? Many thanks in advance Dave (2 Replies)
Discussion started by: davewg
2 Replies

8. Shell Programming and Scripting

Order files by create date

hi Is there a way to sort files in the order they were created ,and move them to another directory one by one ,oldest being the first to be moved. Thanks Arif (4 Replies)
Discussion started by: mab_arif16
4 Replies

9. UNIX for Dummies Questions & Answers

Comparing files named by date/time

I've looked at several of the previous posts and can't seem to find any that pertain to my problem, I'd appreciate some help if possible. I have a directory with numerous logs of various names all named by heading and date ie. dog.20050529.log dog.20050530.log ... (2 Replies)
Discussion started by: gillr
2 Replies
Login or Register to Ask a Question