Can we change the file created date?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Can we change the file created date?
# 1  
Old 12-30-2011
Can we change the file created date?

Hi,

I am creating a file in unix today.
Is it possible to make the file created as 2 days older (or some past date)?
P.S:
i dont want to change the system date to older one and try.Smilie

Thanks,
Pandeeswaran
# 2  
Old 12-30-2011
I Believe you can do this by touch command

Code:
touch newfile #will change modification time to current date and time

Code:
touch -t 8001031305 oldfile  #sets the modification time of oldfile to 13:05 on January 3, 1980.

Code:
touch -r oldfile newfile # sets the modification time of newfile to that of 
oldfile.

These 4 Users Gave Thanks to ambarginni For This Post:
# 3  
Old 12-30-2011
Thanks!! Its awesome!
# 4  
Old 12-30-2011
The file creation date is the one date you cannot change with "touch". You can change the "last accessed" date and/or the "last modified" date.
# 5  
Old 12-30-2011
Quote:
Originally Posted by methyl
The file creation date is the one date you cannot change with "touch". You can change the "last accessed" date and/or the "last modified" date.
So, how we can get the file creation date?

Thanks,
Pandeeswaran
# 6  
Old 12-30-2011
@pandeesh
In modern unix the nearest to file creation date is the "last modification date of the inode".
Code:
ls -ladc oldfile

However this date is unreliable because it can be changed by certain backup software and anything which changes the inode like "chmod" ... and of course the "touch" command itself !
This User Gave Thanks to methyl For This Post:
# 7  
Old 12-30-2011
The file creation date (ctime) is not really the creation date in unix, it is the last time the inode data and some other metadata was modified.

chmod modifies ctime. assume the file is -rwxr-xr-x (755) then
Code:
chmod 755 filename  # you have to own the file to do this

will set ctime to now.

Linux chattr command can also change the ctime.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to check current date file is created and with >0 kb or not for multiple directories

Hi All, I am new in scripting and working in a project where we have RSyslog servers over CentOS v7 and more than 200 network devices are sending logs to each RSyslog servers. For each network devices individual folders create on the name of the each network devices IP addresses.The main... (7 Replies)
Discussion started by: Pinaki
7 Replies

2. Shell Programming and Scripting

Find the file created on current date

Hi All, I'm trying to find a file which is created on current day.... I searched in unix.com and i found, below command. find /land/ -mtime -1 -type f -print | grep "FF_Member_STG.dat" The command checks if the file with name "FF_Member_STG.dat" is created today then exit else proceed. ... (3 Replies)
Discussion started by: ace_friends22
3 Replies

3. UNIX for Dummies Questions & Answers

How to get year part from file created date?

Hi Gurus, I need to get year part of file created date. when using ls -l , it only show month, day and time. is there any option I can add to get year portition? Thanks in advance (7 Replies)
Discussion started by: ken6503
7 Replies

4. Shell Programming and Scripting

Find first created file date in YYYYMMDD format

Hi All, We are copying all the files into ARCHIVE directory after we process them. We are doing this process from last 2 years, now we have a lot of files in ARCHIVE directory. Now I need to find when the first file is copied into this directory? If I Issue, ls -l /ARCHIVE/*.* | tail -1... (3 Replies)
Discussion started by: Raamc
3 Replies

5. Shell Programming and Scripting

Rename File Based on Created Date

I am trying to rename files based on the created/born date of the file. I Have a total of 4000 files that i am trying to do this with and would like it to be log_yyyymmddhh.gz right now the files are maillog.???.gz. Can anyone point me in the right direction of how to get this done via scipt? ... (4 Replies)
Discussion started by: Paulb
4 Replies

6. UNIX for Dummies Questions & Answers

Finding the date a file was created

how do i find the date a file was created? (3 Replies)
Discussion started by: trob
3 Replies

7. UNIX for Dummies Questions & Answers

Move A File With Same Date,don't Change The Desitination Dir Date

Assume, I created one file three years back and I like to move the file to some other directory with the old date (Creation date)? Is it possible? Explain? (1 Reply)
Discussion started by: jee.ku2
1 Replies

8. Shell Programming and Scripting

Need to find created date of file in UNIX

I need to write a script which has to list all the files which are created before six months from now. kindly help on this ... (7 Replies)
Discussion started by: amirthraj_12
7 Replies

9. UNIX for Dummies Questions & Answers

File management based on date created

Hi There, I was wondering how to manage files (ie. rm, cp , mv) based on date last modified and date created. ie. Say i want to: mv ./* ./temp/* (where the date created < 29/1/2006 ) or mv ./* ./temp/* (where the date modified > 27/1/2006 && date modified < 29/1/2006) Thanks in... (1 Reply)
Discussion started by: Geehog_Rare
1 Replies

10. Shell Programming and Scripting

Determine date and time the file was created through shell scripts

Can I determine when the particular file was created, in korn-shell. Can please someone help me. If possible please mail the solution to me. my mail id: bharat.surana@gmail.com (1 Reply)
Discussion started by: BharatSurana
1 Replies
Login or Register to Ask a Question