Home  |  Linux  | Mysql  | PHP  | XML
From:Jim Gibson Date:Tue Mar 16 20:31:33 2010
Subject:Re: running stats on a file
On 3/16/10 Tue Mar 16, 2010 12:18 PM, "ben perl" <ben.perl3@gmail.com>
scribbled:

> Hi Everyone,
>
> I writing this program to check if a file is being touched (linux "touch"
> command) every 25 seconds.I am using stat command on linux.
>
> For example(please check the bold),
>
> stat file
> File: `file'
> Size: 0 Blocks: 0 IO Block: 4096 regular empty
> file
> Device: 803h/2051d Inode: 164394 Links: 1
> Access: (0666/-rw-rw-rw-) Uid: ( 0/ admin) Gid: ( 0/ root)
> Access: 2010-03-16 12:09:03.000000000 -0700
> Modify: 2010-03-16 12:09:03.000000000 -0700
> Change: *2010-03-16 *12:09:03.000000000 -0700 <=


>
> I am just worried about the change attribute above from stat command. So ,
> what i am trying to do convert 12:09:03(as in the example above) into
> seconds and add 25 seconds and convert back into "hour:minutes:seconds"
> format and check the values match.

If you are writing a Perl program, you can use the Perl built-in stat
function that returns 'last modify time' in seconds from the epoch
(1/1/70:00:00:00 UTC), rather than the Linux stat command as above. That
way, you can easily compare times numerically and not worry about converting
between numerical and string forms. See 'perldoc -f stat' for details.

There is also the -M file test operator that returns the age (difference
between the time your program started and the time the file was modified) of
any file in floating-point days (multiply by 86,400 to get age in seconds).
See 'perldoc -f -X' for details.


Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
Re: use with variable
Re: stripped output from Net::SSH2
Re: 1-line datafile, need data for another routine
Re: Simple cgi email
[svn:parrot] r31896 - trunk/compilers/pirc/heredoc



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants