From: sln on
On Mon, 26 Apr 2010 02:13:23 -0700 (PDT), GRP <rengaprasath(a)gmail.com> wrote:

>On Apr 26, 4:44�pm, "John W. Krahn" <some...(a)example.com> wrote:
>> GRP wrote:
>>
>> > I would like to write a script to grep some pattern in few set of log
>> > files and alert it...
>>
>> > In order to avoid duplicate alert i plan to store the "FILENAME:ERR-
>> > LINE-NUMBER:FILE-CREATION-TIME" �in a flat file (colon delimiter) , so
>> > that next time if the same pattern found in same line it will check
>> > against the flat file and won't alert. At the same time if it happens
>> > in different line number it wud check in flat file & the 2nd filed
>> > would be different so it will alert.
>>
>> > Since i can't find a way to get ctime in unix (i tried with perl as
>> > well), would be there any other way to achieve this or better logic?
>>
>> You can get the ctime, that is easy, but you can't get the
>> "FILE-CREATION-TIME" because unix doesn't store that anywhere.
>>
>> John
>> --
>> The programmer is fighting against the two most
>> destructive forces in the universe: entropy and
>> human stupidity. � � � � � � � -- Damian Conway
>
>Mart,
>Thks for the feedback.
>
>I've tried
>($ctime) = (stat($filename))[10];
>
>where that will give only file changed time not creation time
>
>Source : http://perldoc.perl.org/functions/stat.html
> 10 ctime inode change time in seconds since the epoch (*)
>
>John,
>After google it , found Unix wont be storing creation time, just
>thought of checking with you all would there be any other way to
>attain my requirement?
>Basically better logic ;)
>
>Cheers

You can get the current time I assume but why do you need
any time or timestamp at all? You do have modify time in unix
don't you? Thats the creation time the first time.

So, forget about the time. Post some algo that you want this to do.

-sln
From: Ben Morrow on

Quoth jwkrahn(a)shaw.ca:
> GRP wrote:
> >
> > I would like to write a script to grep some pattern in few set of log
> > files and alert it...
> >
> > In order to avoid duplicate alert i plan to store the "FILENAME:ERR-
> > LINE-NUMBER:FILE-CREATION-TIME" in a flat file (colon delimiter) , so
> > that next time if the same pattern found in same line it will check
> > against the flat file and won't alert. At the same time if it happens
> > in different line number it wud check in flat file & the 2nd filed
> > would be different so it will alert.
> >
> > Since i can't find a way to get ctime in unix (i tried with perl as
> > well), would be there any other way to achieve this or better logic?
>
> You can get the ctime, that is easy, but you can't get the
> "FILE-CREATION-TIME" because unix doesn't store that anywhere.

Some Unices do (all the BSDs, for instance), but Perl doesn't provide an
interface to it (except from XS, obviously). I've been wondering about
extending File::stat to support this...

Ben

From: Seebs on
On 2010-04-26, Ben Morrow <ben(a)morrow.me.uk> wrote:
> Some Unices do (all the BSDs, for instance),

??

I don't see anything in stat(2), where should I be looking?

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Ben Morrow on

Quoth Seebs <usenet-nospam(a)seebs.net>:
> On 2010-04-26, Ben Morrow <ben(a)morrow.me.uk> wrote:
> > Some Unices do (all the BSDs, for instance),
>
> I don't see anything in stat(2), where should I be looking?

In my stat(2) (FreeBSD 7.3-RELEASE) I have

| st_birthtime Time when the inode was created.

It's possible this is just a FreeBSD thing, but I thought it was a
4.4-ism.

Ben

From: Seebs on
On 2010-04-26, Ben Morrow <ben(a)morrow.me.uk> wrote:
> Quoth Seebs <usenet-nospam(a)seebs.net>:
>> On 2010-04-26, Ben Morrow <ben(a)morrow.me.uk> wrote:
>> > Some Unices do (all the BSDs, for instance),

>> I don't see anything in stat(2), where should I be looking?

> In my stat(2) (FreeBSD 7.3-RELEASE) I have

>| st_birthtime Time when the inode was created.

> It's possible this is just a FreeBSD thing, but I thought it was a
> 4.4-ism.

Don't see it in NetBSD, so it's not an original 4.4ism. Could be that
newer *BSD have it, but it's not in 4.4. Wish the man page would give
history for that kind of thing.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!