How to find time


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to find time
# 8  
Old 09-25-2006
Quote:
Originally Posted by dakid
what if i dont have perl?
You can get started with the man page on "stat". That should be all you need.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Find gaps in time data and replace missing time value and column 2 value by interpolation in awk

Dear all, I am kindly seeking assistance on the following issue. I am working with data that is sampled every 0.05 hours (that is 3 minutes intervals) here is a sample data from the file 5.00000 15.5030 5.05000 15.6680 5.10000 16.0100 5.15000 16.3450 5.20000 16.7120 5.25000... (4 Replies)
Discussion started by: malandisa
4 Replies

2. UNIX for Dummies Questions & Answers

Find time difference

I have a file wich contains time formats and i need to get the time difference TIME1 TIME2 =============== =================== 20120624192555.6Z 20120624204006.5Z which means first date 2012/6/24 19:25:55,second date 2012/6/24 20:40:06 so when i get the time... (23 Replies)
Discussion started by: wnaguib
23 Replies

3. Shell Programming and Scripting

How to find time difference?

I have a file wich contains time formats and i need to get the time difference TIME1 TIME2 ================================== 20120624192555.6Z 20120624204006.5Z which means first date 2012/6/24 19:25:55,second date 2012/6/24 20:40:06 so when i get the time... (1 Reply)
Discussion started by: wnaguib
1 Replies

4. Shell Programming and Scripting

what would a script include to find CPU's %system time high and user time high?

Hi , I am trying to :wall: my head while scripting ..I am really new to this stuff , never did it before :( . how to find cpu's system high time and user time high in a script?? thanks , help would be appreciated ! :) (9 Replies)
Discussion started by: sushwey
9 Replies

5. Linux

Find last system shut down time

Hi, I need to find the last system shutdown time. I got a command last that is used for this.But the command is not give the year. Below i posted the sample output last -x |grep shutdown shutdown system down 2.6.31.5-server- Tue Jan 11 11:45 - 11:46 (00:00) shutdown system down ... (6 Replies)
Discussion started by: maruthu
6 Replies

6. Shell Programming and Scripting

Find and Convert UTC Time to PST Time

Hello All - I have a script that grabs data from the net and outputs the following data 46029 46.144 -124.510 2010 07 26 22 50 320 4.0 6.0 2.2 9 6.8 311 1012.1 -0.9 13.3 13.5 13.3 - - 46041 47.353 -124.731 2010 07 26 22 50 250 2.0 3.0 1.6 8 6.4 - 1011.6 - ... (0 Replies)
Discussion started by: drexnefex
0 Replies

7. AIX

How to find time difference between 2 timestamps?

HI All, can some one please help me how to fine the difference between two time stamps say a= Nov 10, 2009 9:21:25 AM b= Nov 10, 2009 10:21:25 AM I want to find difference between the a & b I googled and tried with some options but no luck. My OS is AIX (1 Reply)
Discussion started by: bandlan9
1 Replies

8. Shell Programming and Scripting

how to find the time before 30 minutes

Hi All, I want to find out the time before 30 minutes. I am able to do with in hours limit. date Fri Aug 21 06:50:00 BST 2009 TZ=CST+1 date Fri Aug 21 04:50:02 CST 2009 Can any one please help me (6 Replies)
Discussion started by: vikash_k
6 Replies

9. Solaris

find files by time

I'm working on a SunOS 5.8 box and I have to search recursively in directories matching a certain pattern for files with a .log extension that have changed within the last n-minutes, and than select the least recently used file and open it for reading, preferrably with tail. Does anyone know how I... (3 Replies)
Discussion started by: rein
3 Replies

10. UNIX for Dummies Questions & Answers

Can any how we can find the time diffrence...?

Hi, I am trying to caluate the time elasped by the job to run.For that i have used the following command: I have one file which contains the following more start.txt 991 STARTED Fri Aug 10 14:04:20 2007 Starting Job JOB_NAME. (...) 1036 STARTED Fri Aug 10 14:04:31 2007 ... (1 Reply)
Discussion started by: Amey Joshi
1 Replies
Login or Register to Ask a Question
apache_mod_perl-108~358::mod_perl-2.0.7::docs::api::APR:UserfContributed Perl Docapache_mod_perl-108~358::mod_perl-2.0.7::docs::api::APR::Finfo(3)

NAME
APR::Finfo - Perl API for APR fileinfo structure Synopsis use APR::Finfo (); use APR::Const -compile => qw(FINFO_NORM); my $finfo = APR::Finfo::stat("/tmp/test", APR::Const::FINFO_NORM, $pool); $device = $finfo->device; # (stat $file)[0] $inode = $finfo->inode; # (stat $file)[1] # stat returns an octal number while protection is hex $prot = $finfo->protection; # (stat $file)[2] $nlink = $finfo->nlink; # (stat $file)[3] $gid = $finfo->group; # (stat $file)[4] $uid = $finfo->user; # (stat $file)[5] $size = $finfo->size; # (stat $file)[7] $atime = $finfo->atime; # (stat $file)[8] $mtime = $finfo->mtime; # (stat $file)[9] $ctime = $finfo->ctime; # (stat $file)[10] $csize = $finfo->csize; # consumed size: not portable! $filetype = $finfo->filetype; # file/dir/socket/etc $fname = $finfo->fname; $name = $finfo->name; # in filesystem case: # valid fields that can be queried $valid = $finfo->valid; Description APR fileinfo structure provides somewhat similar information to Perl's "stat()" call, but you will want to use this module's API to query an already "stat()'ed" filehandle to avoid an extra system call or to query attributes specific to APR file handles. During the HTTP request handlers coming after "PerlMapToStorageHandler", "$r->finfo" already contains the cached values from the apr's "stat()" call. So you don't want to perform it again, but instead get the "ARP::Finfo" object via: my $finfo = $r->finfo; API
"APR::Finfo" provides the following functions and/or methods: "atime" Get the time the file was last accessed: $atime = $finfo->atime; obj: $finfo ( "APR::Finfo object" ) return: $atime ( integer ) Last access time in seconds since the epoch since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[8] Note that this method may not be reliable on all platforms, most notably Win32 -- FAT32 filesystems appear to work properly, but NTFS filesystems do not. "csize" Get the storage size consumed by the file $csize = $finfo->csize; obj: $finfo ( "APR::Finfo object" ) return: $csize ( integer ) since: 2.0.00 Chances are that you don't want to use this method, since its functionality is not supported on most platforms (in which case it always returns 0). "ctime" Get the time the file was last changed $ctime = $finfo->ctime; obj: $finfo ( "APR::Finfo object" ) return: $ctime ( integer ) Inode change time in seconds since the epoch since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[10] The ctime field is non-portable. In particular, you cannot expect it to be a "creation time", see "Files and Filesystems" in the perlport manpage for details. "device" Get the id of the device the file is on. $device = $finfo->device; obj: $finfo ( "APR::Finfo object" ) return: $device ( integer ) since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[0] Note that this method is non-portable. It doesn't work on all platforms, most notably Win32. "filetype" Get the type of file. $filetype = $finfo->filetype; obj: $finfo ( "APR::Finfo object" ) return: $filetype ( ":filetype constant" ) since: 2.0.00 For example: use APR::Pool; use APR::Finfo; use APR::Const -compile => qw(FILETYPE_DIR FILETYPE_REG FINFO_NORM); my $pool = APR::Pool->new(); my $finfo = APR::Finfo::stat("/tmp", APR::Const::FINFO_NORM, $pool); my $finfo = $finfo->filetype; if ($finfo == APR::Const::FILETYPE_REG) { print "regular file"; } elsif ($finfo == APR::Const::FILETYPE_REG) { print "directory"; } else { print "other file"; } Since /tmp is a directory, this will print: directory "fname" Get the pathname of the file (possibly unrooted) $fname = $finfo->fname; obj: $finfo ( "APR::Finfo object" ) return: $filetype ( string ) since: 2.0.00 "group" Get the group id that owns the file: $gid = $finfo->group; obj: $finfo ( "APR::Finfo object" ) return: $gid ( number ) since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[5] Note that this method may not be meaningful on all platforms, most notably Win32. Incorrect results have also been reported on some versions of OSX. "inode" Get the inode of the file. $inode = $finfo->inode; obj: $finfo ( "APR::Finfo object" ) return: $inode ( integer ) since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[1] Note that this method may not be meaningful on all platforms, most notably Win32. "mtime" The time the file was last modified $mtime = $finfo->mtime; obj: $finfo ( "APR::Finfo object" ) return: $mtime ( integer ) Last modify time in seconds since the epoch since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[9] "name" Get the file's name (no path) in filesystem case: $name = $finfo->name; obj: $finfo ( "APR::Finfo object" ) return: $device ( string ) since: 2.0.00 "nlink" Get the number of hard links to the file. $nlink = $finfo->nlink; obj: $finfo ( "APR::Finfo object" ) return: $nlink ( integer ) since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[3] "protection" Get the access permissions of the file. Mimics Unix access rights. $prot = $finfo->protection; obj: $finfo ( "APR::Finfo object" ) return: $prot ( ":fprot constant" ) since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[2] Note: Perl's stat returns an octal number while mod_perl's "protection" returns a hex number. See perldoc -f stat and APR's file_io for more information on each. "size" Get the size of the file $size = $finfo->size; obj: $finfo ( "APR::Finfo object" ) return: $size ( integer ) Total size of file, in bytes since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[7] "stat" Get the specified file's stats. $finfo = APR::Finfo::stat($fname, $wanted_fields, $p); arg1: $fname ( string ) The path to the file to "stat()". arg2: $wanted_fields ( ":finfo constant" ) The desired fields, as a bitmask flag of "APR::FINFO_*" constants. Notice that you can also use the constants that already combine several elements in one. For example "APR::Const::FINFO_PROT" asks for all protection bits, "APR::Const::FINFO_MIN" asks for the following fields: type, mtime, ctime, atime, size and "APR::Const::FINFO_NORM" asks for all atomic unix "apr_stat()" fields (similar to perl's "stat()"). arg3: $p ( "APR::Pool object" ) the pool to use to allocate the file stat structure. ret: $finfo ( "APR::Finfo object" ) since: 2.0.00 For example, here is how to get most of the "stat" fields: use APR::Pool (); use APR::Finfo (); use APR::Const -compile => qw(FINFO_NORM); my $pool = APR::Pool->new(); my $finfo = APR::Finfo::stat("/tmp/test", APR::Const::FINFO_NORM, $pool); "user" Get the user id that owns the file: $uid = $finfo->user; obj: $finfo ( "APR::Finfo object" ) return: $uid ( number ) since: 2.0.00 This method returns the same value as Perl's: (stat $filename)[4] Note that this method may not be meaningful on all platforms, most notably Win32. "valid" The bitmask describing valid fields of this apr_finfo_t structure including all available 'wanted' fields and potentially more $valid = $finfo->valid; obj: $finfo ( "APR::Finfo object" ) arg1: $valid ( bitmask ) This bitmask flag should be bit-OR'ed against ":finfo constant" constants. since: 2.0.00 See Also mod_perl 2.0 documentation. Copyright mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. Authors The mod_perl development team and numerous contributors. perl v5.16.2 2011-02-07 apache_mod_perl-108~358::mod_perl-2.0.7::docs::api::APR::Finfo(3)