UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 8th, 2007, 08:01 AM
livingsword livingsword is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 12 livingsword User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 6 sec
Reputation Power: 0
How to get the file creation date ?

well, im trying to list all files created today. The problem is , all i can find is the modification date. Even the options like -atime, ctime in find command refer to the modification date.

Is there any command i could use for finding out file creation date ? or may be any other method ??

Thanks for helping out.

Reply With Quote
  #2  
Old June 8th, 2007, 08:30 AM
mu's Avatar
mu mu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Location: Dublin, Ireland
Posts: 174 mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 23 h 39 m 56 sec
Reputation Power: 39
This depends on what filesystem you're using. Generally though the creation time isn't stored. Ctime actually records the time of the last status change. Changing permissions or renaming the file will result in the ctime being updated. Certain filesystems do record files' creation times, at least ZFS does anyway (crtime).

Reply With Quote
  #3  
Old June 8th, 2007, 08:51 AM
livingsword livingsword is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 12 livingsword User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 6 sec
Reputation Power: 0
Thanks. i went through the wiki on ZFS, and it is mentioned that it cannot be ported on Linux distros due to some licensing issue. So does that mean , theres no way of determining file creation date on a linux distro like Red Hat ??

Reply With Quote
  #4  
Old June 8th, 2007, 09:56 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 813 SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 6 h 38 m 32 sec
Reputation Power: 344
You will find that even with file sytems that hold creaton date (and I think most do) there is no way, direct from the shall prompt to obatin it. You will need to engage another programming environment (perl springs to mind) to show it.
__________________
"I feel so miserable without you; it's almost like having you here" - Stephen Bishop

Reply With Quote
  #5  
Old June 8th, 2007, 10:44 AM
livingsword livingsword is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 12 livingsword User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 6 sec
Reputation Power: 0
any hints on how can i go about doing that ? im pretty much a noob.

Reply With Quote
  #6  
Old June 9th, 2007, 11:08 AM
livingsword livingsword is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 12 livingsword User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 6 sec
Reputation Power: 0
ok, i tried it with perl and i've managed to reach upto this point ,

Code:

perl -e 'use File::stat; 

use Time::localtime; 

$file='/mnt'; 

$date_string = ctime(stat($file)->mtime); 

print "file $file created at $date_string\n";' 


But when i try to run the script , i get error "search field incomplete".

Please help.

Reply With Quote
  #7  
Old June 10th, 2007, 10:14 AM
ghostdog74 ghostdog74 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 104 ghostdog74 User rank is Lance Corporal (50 - 100 Reputation Level)ghostdog74 User rank is Lance Corporal (50 - 100 Reputation Level)ghostdog74 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 21 h 15 m 52 sec
Reputation Power: 3
you can try stat.
Code:
stat -c "%y" file

check your man page.

Reply With Quote
  #8  
Old June 11th, 2007, 12:22 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 6 h 19 m 24 sec
Reputation Power: 48
Shells and utilities like ls and date generally try to conform to a set of standards - POSIX.

The standard says that three filetimes are recorded - access time, modification time, and inode change time - atime, mtime, ctime. It also says these three are the only filetimes that will be shown for a file.

If you find a filesystem that supports a fourth filetime, creation time, it is actually an oddity, and most everything out there will not be able to support it.

In fact, date -r <filename> shows mtime, according to the man page. stat does the same - only shows file modification time. And these are GNU extensions, available on with GNU utilities, and by default, on linux boxes. "Regular" unix distributions do not have stat and the -r option for date.

The short answer is: there are no file creation times in UNIX. It is a windows thing.

Reply With Quote
  #9  
Old July 20th, 2007, 09:51 AM
tonv tonv is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 1 tonv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 52 sec
Reputation Power: 0
time that file is update

do you search this ?


#! /usr/bin/perl
use File::stat;
use Time::localtime;
$file='path//to/filename';
$date_string =ctime(stat($file)->mtime);
print "file $file update at $date_string\n";

Reply With Quote
  #10  
Old July 21st, 2007, 01:57 AM
n1np's Avatar
n1np n1np is offline
User
Click here for more information
 
Join Date: Jan 2005
Location: Alleghany Highlands
Posts: 112 n1np User rank is Captain (20000 - 30000 Reputation Level)n1np User rank is Captain (20000 - 30000 Reputation Level)n1np User rank is Captain (20000 - 30000 Reputation Level)n1np User rank is Captain (20000 - 30000 Reputation Level)n1np User rank is Captain (20000 - 30000 Reputation Level)n1np User rank is Captain (20000 - 30000 Reputation Level)n1np User rank is Captain (20000 - 30000 Reputation Level)n1np User rank is Captain (20000 - 30000 Reputation Level)n1np User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 1849183 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1849183 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1849183 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1849183 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1849183 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1849183 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1849183 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1849183 Folding Title: Super Ultimate Folder - Level 4Folding Points: 1849183 Folding Title: Super Ultimate Folder - Level 4
Time spent in forums: 2 Weeks 3 Days 1 h 17 m 31 sec
Reputation Power: 223
To add to the confusion, in FreeBSD (UFS) there is, in addition to the times of file access, file modification, and inode change,
Code:
$ stat -f %B $filename

which the stat manpage claims to give "the birth time of the inode". So we can know the creation time of the inode, but not necessarily the creation time of the file.

Curious .

Ben N1NP
__________________

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > How to get the file creation date ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT