1

I need to have a java program always running in the background. I've set it up as a SQL Job that runs periodically, running the Java from CMD. The job runs periodically to check if the Java program is still active.

The issue I'm encountering is that if I stop the SQL Job, the Java program seems to continue running. I need a way to stop the program. Without the ability to stop the Java program, I can't rerun the Job.

Any ideas?

Gidil
  • 4,137
  • 2
  • 34
  • 50
  • you might find useful these https://stackoverflow.com/questions/12263337/how-to-catch-the-exit-code-of-a-cmdexec-sql-server-job and https://www.manageengine.com/products/desktop-central/returning-error-code-on-scripts-how-to.html. sorry no solution, last time I was dealing with similar things was around 2010 - don't remember exactly, but it has to do something with passing around exit codes. – Drako Jun 20 '17 at 11:09
  • by the way you could improve your question - because sentence one states you need java always running and then you complain it does not stop :) but I hope I understood your needs correctly :) – Drako Jun 20 '17 at 11:10
  • in my first comment I meant - no exact solution - but I remember similar things working for me, but exit codes should be set correctly in scripts, not only at the end but for methods as well – Drako Jun 20 '17 at 11:20

1 Answers1

0

With the given information, I understand, that although you are periodically starting your Java program, it is not exiting.
Maybe you should check if your Java program ever exits.
If it does, then from your Java program, you could check if the corresponding job is enabled/disabled in the sysjobs table, and decide whether or not to stop running the Java program.