LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Retaining timestamp of a directory. (https://www.linuxquestions.org/questions/linux-newbie-8/retaining-timestamp-of-a-directory-934047/)

sysmicuser 03-12-2012 09:44 AM

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??

rknichols 03-12-2012 10:33 AM

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.

chrism01 03-13-2012 01:09 AM

I think an auditor would want to see the timestamp changed/correct ....

sysmicuser 03-13-2012 06:19 AM

@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.

chrism01 03-13-2012 08:04 PM

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 ...

sysmicuser 03-15-2012 07:10 AM

@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 !

Tinkster 03-15-2012 11:13 PM

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


All times are GMT -5. The time now is 02:25 AM.