On Wed, 09 Aug 2006 13:17:11 +1200
Phill Coxon <[EMAIL PROTECTED]> wrote:
> Hi,
>
> ** Can someone tell me how to detect if a file exists using bash?
if [ -f $file ]
then
....
fi
There's also -z, -r, etc.
>
> I need to check for the file periodically (via cron) and if it
> disappears, copy a backup of the file to replace it.
>
> I have a client with a dedicated server where a very important
> configuration file keeps disappearing for no explainable reason.
>
> So we need a script to regularly check every that the file is there and
> replace it when it disappears so that his web site services keep
> running.
>
> As to why it's disappearing...no idea. I'm starting to suspect it may
> be malicious code that a previous programmer installed to delete the
> config file so he would pick up the "maintenance" work. I've had a good
> look around but haven't found anything yet.
>
> Which leads to a second question:
>
> ** Is there any way to monitor a file and log which processes or scripts
> access and / or modify it?
>
> Thanks!
>
>
>
One I didn't mention last night... fcheck. If your distro doesn't support it,
then there's always http://www.geocities.com/fcheck2000/FCheck_2.07.59.tar.gz
Steve
PS. Yes, you're right to be paranoid (: