From: GRP on
hi,

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?

Your help will be greatly appreciated..

thks
From: Mart van de Wege on
GRP <rengaprasath(a)gmail.com> writes:

>
> 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?
>
What's wrong with

($ctime) = (stat($filename))[10];

?

Mart

--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.
From: John W. Krahn on
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
From: GRP on
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
From: Mart van de Wege on
GRP <rengaprasath(a)gmail.com> writes:

> 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

Note: Don't quote sigs, it's considered impolite.
>
> Mart,
> Thks for the feedback.
>
> I've tried
> ($ctime) = (stat($filename))[10];
>
> where that will give only file changed time not creation time
>
Ah.

I *was* wondering about that. Your use of creation time was inconsistent
with your asking for ctime. On Unix, these *are* different things, and
as pointed out, creation time is not saved.

Regards,

Mart

--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.