LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 03-12-2012, 09:44 AM   #1
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Rep: Reputation: 0
Retaining timestamp of a directory.


Hallo Folks,

Quite often when we do an operation in a directory the timestamp of directory changes.
Say we did vi any new file to perfomed any write operation in that directory?

Is there anyway I can retain timestamp? so I can save my arse for audit ?

---------- Post added 03-13-12 at 01:45 AM ----------

For a file it is quite easy,

I normally do cp -pavf file file_backup

and then again
cp -apvf file_backup file

what about directory??
 
Old 03-12-2012, 10:33 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Code:
touch -r some_directory /tmp/time.somedir  # Save the current timestamp
... # Do stuff that affects some_directory
touch -r /tmp/time.somedir some_directory  # Restore the saved timestamp
rm /tmp/time.somedir
It is important that the file that records the time stamp is saved somewhere other than in the directory of interest so that the file can be later removed without affecting the directory.
 
1 members found this post helpful.
Old 03-13-2012, 01:09 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I think an auditor would want to see the timestamp changed/correct ....
 
Old 03-13-2012, 06:19 AM   #4
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@rknichols
Many thanks for that, yep it works beautifully.

@chrism01

I do agree and understand but sometimes you need a changed timestamp to original in case if your scripts runs on "flag" mode and is depenedent on timestamp.
 
Old 03-13-2012, 08:04 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Well, unless you have another way of recording each change to the dir, I still say the auditor is not going to be happy ...
YMMV, depending on the auditor ...
 
Old 03-15-2012, 07:10 AM   #6
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@chrism01

I want to fool the auditors! Nothing nasty but I believe in ideas and not hierarchy! for some crappy reason big fat cat siting in our organization is a compelete headless b@st@srd !
 
Old 03-15-2012, 11:13 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Ummm ... you're entitled to your view(s), but if a) your organisation feels the need to
have audits, and b) the corporate policy for those is accepted you're in breach of some
rule or other with that approach of yours. Unless there's something you NEED to hide an
audit item can be a) explained, or b) amended to not re-occur if it doesn't sit well with
the companies processes. c) might be that you're doing nastys after all ...

Anyway, trying to weasel out of something in your employment agreement puts you in breach
of LQs rules, too.



Closing this ...



Cheers,
Tink
 
1 members found this post helpful.
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Updating timestamp in files in directory tuxtutorials Programming 5 08-21-2010 09:03 AM
sort oldest 5 files in a directory tree recursively based on timestamp Linux abhelp Programming 1 06-04-2010 04:58 AM
Intstall Firefox 3.0 while retaining FF 2.0 raypen Slackware 9 10-04-2008 04:10 PM
Retaining format Labman Linux - Newbie 5 05-04-2008 05:48 PM
retaining root authorisation in X shamrock_uk Mandriva 2 06-22-2004 08:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration