Operating System - HP-UX
1821584 Members
3609 Online
109633 Solutions
New Discussion юеВ

Can we change creation date of a file

 
SOLVED
Go to solution
Ezhilarasan
Occasional Advisor

Can we change creation date of a file

Hi,

I thing there is some way to change the
creation time stamp (date) of a file to
some old date.

Regards
R. Ezhil
7 REPLIES 7
Michael Tully
Honored Contributor

Re: Can we change creation date of a file

Use the touch command

Top change the file test from it's current date to 28 Oct 2002 at 15:30

# touch -t 0210281530 test

Have a look at the man page for 'touch'
# man touch
Anyone for a Mutiny ?
Ian Kidd_1
Trusted Contributor

Re: Can we change creation date of a file

on a HP-UX 11.00 system you can use touch -t. I personally wouldn't use it just because I like to be able to believe in the timestamps. Do a man on touch for specific format.

By the way, I don't believe -t works on 10.20.

I'll say it again, I'd rather not use it, and if you do, test thoroughly on an testfile.
If at first you don't succeed, go to the ITRC
Patrick Wallek
Honored Contributor
Solution

Re: Can we change creation date of a file

You can use 'touch' to do this.

# touch -t 200212251530 testfile

Will create a file called testfile with a time stamp of Dec. 25, 2002 at 15:30.

If you run this against an existing file, it will change the time stamp to what you specify.

# man touch

for more information.
RAC_1
Honored Contributor

Re: Can we change creation date of a file

there are three time stamps associated with file

atime - access time
ctime - change time
mtime - modification time

what you get in ll is access time. you can change it with touch command. so that need not be creation time. (it could be if file has not been modified since creation i.e ctime is the creation time if the file is not modified)

Check man page of touch.
There is no substitute to HARDWORK
Ravi_8
Honored Contributor

Re: Can we change creation date of a file

Hi,

It's possible using 'touch' command
$touch -t yyyymmddhhmm

where yyyy - year
mm - month
dd - date
hh - hour
mm - minute
never give up
Dietmar Konermann
Honored Contributor

Re: Can we change creation date of a file

The ll command shows the mtime, last modification while ll -u shows the atime, last access.

The touch -t cannot change the ctime (although s touch w/o -t does!). BTW, also the corresponding syscall utime(2) does not change the ctime. So there seems to be no easy way do do it.

Best regards...
Dietmar.


"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Dietmar Konermann
Honored Contributor

Re: Can we change creation date of a file

Just found the reason, _why_ this is not possible. The ctime is not the creation time, it's the time of last change.

Whenever the inode is changed, ctime is updated. So even the changing of the timestamps updates the inode and gets the ctime updated also. Changing the ctime alone would not make sense, since this change itself would be updating ctime back to the current time.

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)