LinuxQuestions.org
Visit Jeremy's Blog.
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: 353

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: CentOS
Posts: 3,463

Rep: Reputation: 1518Reputation: 1518Reputation: 1518Reputation: 1518Reputation: 1518Reputation: 1518Reputation: 1518Reputation: 1518Reputation: 1518Reputation: 1518Reputation: 1518
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: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
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: 353

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: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
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: 353

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: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration