We help IT Professionals succeed at work.

Getting notification upon code pausing execution.

bfuchs
bfuchs asked
on
164 Views
Last Modified: 2019-02-05
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
Comment
Watch Question

Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
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.
CERTIFIED EXPERT

Author

Commented:
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
Daniel PineaultPresident / Owner CARDA Consultants Inc.
CERTIFIED EXPERT
Distinguished Expert 2018

Commented:
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.
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
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.
CERTIFIED EXPERT

Author

Commented:
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
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
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.
President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Author

Commented:
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
Daniel PineaultPresident / Owner CARDA Consultants Inc.
CERTIFIED EXPERT
Distinguished Expert 2018

Commented:
Jim, but what guarantees the 2nd db is running?
CERTIFIED EXPERT

Author

Commented:
@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
Daniel PineaultPresident / Owner CARDA Consultants Inc.
CERTIFIED EXPERT
Distinguished Expert 2018

Commented:
Valid point.
Jim Dettman (EE MVE)President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017

Commented:
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.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.