Link to home
Start Free TrialLog in
Avatar of onepiolin
onepiolin

asked on

Script to test for file and then write into log

I'm in a little bind.

I have a MS SQL database that does nightly backups and creates a file every night that needs to be backed up.

I need to find a way to test that a backup file was created within the  last 24 hours and if it hasn't, to write to the Windows Logs so that an agent can alert me that there's been an issue.

I do not want to only rely on MS Sql Studio to let me know of failure but I want a Windows way to record this for redundancy.

All the monitoring software that I've found will keep track of changes but I don't know of any that will test a directory for a file and only trigger when the file is not there.

I'm thinking powershell but I don't know the language or even if it's able to do it.

Any suggestions (or a sample script) will be greatly appreciated.
Avatar of Bill Prew
Bill Prew

How do you want to find the file?  Is it always the same name, and you just want to check the created time?  Or does the name change with each backup, etc?

I assume you mean place an entry into a windows event log, and if so which one?

~bp
Avatar of onepiolin

ASKER

Ideally, I'd like to load a batch or powershell file in the Task Scheduler.

The way the SQL Studio works right now is that a file with a random name is created nightly in a specific folder. I just want to check for the creation / modified timestamp. If there isn't a file there that is less than 24 hours old (within a day), I'd like to know about it.

Any of the logs would work but my preference would be the Application Log. I'm using Labtech monitoring software and it can flag when a specific event occurs, so I can check for that event.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much.

I'll test and report.
This is awesome. It works on my workstation, now I need to tweak for weekends and run in on the server.
I appreciate the time. Thanks you!
Welcome.

~bp