Operating System - HP-UX
1833163 Members
3685 Online
110051 Solutions
New Discussion

file re-created? How to know?

 
SOLVED
Go to solution
yyghp
Super Advisor

Re: file re-created? How to know?

BTW, if I set mode "s" to UID with "chmod u+s ", what's the best way to check whether the "s" bit has been set to the file during my next scan?
I still don't like to use "ll" with "cut" to get the status of the "flag".
Any other good idea?
yyghp
Super Advisor

Re: file re-created? How to know?

BTW, if I set mode "s" to UID with "chmod u+s ", what's the best way to check whether the "s" bit has been set to the file during my next scan?
I still don't like to use "ll" with "cut" to get the status of the "flag".
Any other good idea to check the bit of the permission mode status?
Ivan Ferreira
Honored Contributor

Re: file re-created? How to know?

I think that your best option is to enable auditing.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
James R. Ferguson
Acclaimed Contributor

Re: file re-created? How to know?

Hi:

If the only state information you retain is a last line number than the best you can do is to assume a new log has been created if your saved line number is greater than the current log's number of lines.

In my original post, I said that "good" log file would have some indication of the time of an event beyond just the ordinal occurance of an event. You could save knowledge of *both* the line number and all or part of the line where you last left off. Then, when you scan again, if you find that your restart point is different (data-wise) you start from the log's beginning.

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: file re-created? How to know?

Couldn't be simler.

test -u. Man test for details.

FILENAME=myfile
if [[ -u "${FILENAME}" ]]
then
echo "Setuid bit is set"
else
echo "It ain't"
fi
If it ain't broke, I can fix that.
JASH_2
Trusted Contributor

Re: file re-created? How to know?

yyqhp,

The cat /dev/null > logfile creates a zero legnth logfile after the copy, so all old errors deleted.

I see better answers after mine, but thought I would answer your question.

Cheers,

JASH
If I can, I will!