- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Change DateTimeStamp
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2006 02:06 AM
тАО04-30-2006 02:06 AM
Change DateTimeStamp
1) I want to modify a shell script (or any file type ) in Unix. But after making modifications and saving , it should preserve the actual date and not the date when i modified it ...is it possible?
OR
2) If there are no options to preserve timestamp while saving..Let me modify the file and save it in current date. Later , is it possible to change the datetime stamp on that particular file to some earlier date?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2006 02:50 AM
тАО04-30-2006 02:50 AM
Re: Change DateTimeStamp
First, UNIX does not matain a "creation" timestamp. A modification timestamp, a lastaccess timestamp and a timestsmp that reflects the last change in the file's inode information exist, but no others.
That said, you can alter the modification and/or lastaccess timestamps to anything you choose with 'touch'.
For example to change the last modification time of 'myfile' to yesterday (April 29) at 0001, do:
# touch -mt 04290001 myfile
...or:
To set the timestamp's of 'myfile' equal to 'yourfile' do:
# touch -am -r yourfile myfile
Now, beware that resetting a file's modification time may affect increamental backup runs and remote file distriubtion utilities, both of which use a file's modification timestamp for tracking.
Read the manpages for 'touch(1)' and for 'rdist(1)' for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2006 03:05 AM
тАО04-30-2006 03:05 AM
Re: Change DateTimeStamp
http://docs.hp.com/en/B2355-60127/touch.1.html
Looks like your option 2) is doable with it, at least with HP-UX 11.11 and above.
Your option 1) would be possible only if the editor you use would explicitly re-set the timestamp(s) back to the original value after saving the modified file. Some editors might have such an option, but certainly not all of them.
Note that there are three timestamps associated with each file: the access time (atime), time of last modification of file contents (mtime) and time of last change of file attributes (ctime) like name, ownership, protection and mtime.
Only atime and mtime are changeable by a normal user, and those can be set to a non-current value only if the user actually owns the file.
There is apparently no way to change the ctime to any other value than the present moment. This is to make forgeries more difficult in a multi-user environment.
Of course, anything is possible if you are root and can access the disk directly, bypassing the filesystem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2006 06:32 AM
тАО04-30-2006 06:32 AM
Re: Change DateTimeStamp
WHY would you want to engage in such confusing practice?
Even when making say a benign change in the comments to a program source and you think it wise to fool the make utility in thinking the tree is still up to date it still seems bad practice. It's bound to bite you or your succesor when and where it hurts eventually.
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2006 07:10 AM
тАО05-01-2006 07:10 AM
Re: Change DateTimeStamp
Actually we deal with lots of Manual file moves/copies. Sometimes it happens we make mistakes while copying file from one location to other. In such cases , file timestamp changes and its hard to keep track of when did the file really land in our system (from other sources). We usually use
mv , cp -p to preserve timestamps...sometime by mistake we just use cp and loose the timestamp..
so just to bring it back to original timestamp...we need to know how to change the timestamp.
Hope i made myself clear.
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2006 07:29 AM
тАО05-01-2006 07:29 AM
Re: Change DateTimeStamp
Have a look at the 'touch' man page for more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2006 07:49 AM
тАО05-01-2006 07:49 AM
Re: Change DateTimeStamp
Thanks for that explanation.
I like it much better than the original question.
Some (linux) versions of 'touch' actually have an easy provision for this: -r ref_file (as JRF already pointed out)
Btw.. you seem to frequent the forum a bit. Please read up on some guidelines such as: http://forums1.itrc.hp.com/service/forums/helptips.do?#28
This will allow others to see whether the question received a useful answer or not. And it will show you how to 'close' a topic when it is no longer interesting for you.
Regards,
Hein.