Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

asked on

Getting notification upon code pausing execution.

Hi Experts,
I have some (Access) code that is supposed to be running all the time.
Would like to get an email notification in case the code stops executing for whatever reason.
What is the best way to accomplish that?
Thanks
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

If it's because of an error then you could add an error routine or routines that display a msgbox and/or sends you an email when the error happens. If it's not then without some external program checking some value produced by the Access program I don't how how you'd do it.
Avatar of bfuchs

ASKER

Hi,
If it's not then without some external program checking some value produced by the Access program...
Perhaps upon starting the Access code we can get the handle of the Access program, then have a batch file start looking for that handle id and if doesn't find it, send an email...
Does that make sense?
Thanks,
Ben
Avatar of Daniel Pineault
Daniel Pineault

Stops running how?  An error?  The user stops it?  Something else?

If you mean an error, then add an error handler that included an email routine (SendObject is the simplest way to do this).
If you mean the user stops it, then the question becomes how do they stop it?  Close, cancel button, ... you'd need to trap the button click, form closure, ... and use a similar email routine as previously mentioned.
If it's stopped by the db being closed, then open a hidden form at the startup, and use that's form's close event to send an email.  Thus when the db is closed, it will first close the hidden form triggering the email.
Perhaps upon starting the Access code we can get the handle of the Access program, then have a batch file start looking for that handle id and if doesn't find it, send an email...
Does that make sense?
Yes.
Avatar of bfuchs

ASKER

Stops running how?  An error?  The user stops it?  Something else?
This will be placed on the server and keep running indefinitely, no user intervention.

What I'm looking to oversee is

 A) If got stuck by an unhandled error event.
 B) System crash.
 C) Server restart w/o restarting the program.
 D) Hardware failure etc...

Any idea how to put it to work the idea mentioned above?

Thanks,
Ben
If the code stops executing, it stops, thus cannot do anything like sending an e-mail.

So, you will have to generate some kind of heartbeat with a certain interval, then watch if this stops.
You could:
  • send an e-mail as the heartbeat; if the e-mails stop arriving, the application has stopped.
  • create a log file and have another application to watch this; if no new entry is created, an e-mail will be sent to you
  • create a syslog entry if you have a syslog server running

What to choose depends very much on your scenario.
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

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
Avatar of bfuchs

ASKER

Thanks to all participants!

@Jim,
I was thinking (this morning) about similar approach.
To have a file on the server and every time the code runs modify that file, then later have a program examining the time of that file last updated...

Thanks,
Ben
Jim, but what guarantees the 2nd db is running?
Avatar of bfuchs

ASKER

@Daniel,
Once I have this split into two applications, and they can be running in separate servers, it should be solving most of my concerns, as very unlikely both servers are down at the same time.
Thanks,
Ben
Valid point.
Apologies to all....I am not getting any notifications on my questions.

@Daniel,

<<Jim, but what guarantees the 2nd db is running?>>

 The first.  They check each other.

@Ben,
<<Once I have this split into two applications, and they can be running in separate servers, it should be solving most of my concerns, as very unlikely both servers are down at the same time.>>

 Exactly.   You'd want them running on separate servers to cover all the bases.  But in the example above, these happen to be running on the same server.  It would have been better had they not been though.

 Even so, it's rare for a server to be down (lots of other things get noticed) and it's never been an issue.   This setup has been running for over fifteen years and I'm sorry to say, the server has never been the problem<g>.

Jim.