?
Solved

Kill / respawn application automatically every X minutes

Posted on 2011-10-02
5
Medium Priority
?
448 Views
Last Modified: 2012-06-27
Hello everyone,

I have an application that I need to let run in the background to handle some tasks on a Windows Server 2008 machine. The problem is, there are some bugs in the application that cause it to crash/hang between every 60 to 120 minutes. I don't have the source code so I can't really jump in and isolate the problem...

I do need to keep this application up and running in the meantime until I find a replacement, so it looks like my only option would be to:

1. Automatically kill / respawn this program every X minutes (say, every 45 minutes)
2. Catch any apphang/appcrash errors and kill / respawn the program upon detection.

With regards to #2, when an app crashes / hangs... it appears that the process isn't killed. It just gives me an option "Close this program" or "Check for a solution online." Is there a way to avoid this so that when the app crashes or hangs the process is just allowed to die without any user input... this way the solution above can identify a missing process?



Is there a way to do this with a simple windows batch script or maybe some existing 3rd party software? Or should I look into trying to write something in C#?
0
Comment
Question by:mcainc
  • 3
5 Comments
 
LVL 12

Accepted Solution

by:
Chris earned 2000 total points
ID: 36900684
You could use the 'taskkill' command within a batch file as long as you know the image name of the process. The below command would force kill all notepad instances:

Taskkill /f /im notepad.exe

You could then relaunch the application using the 'start' command.

Just stick this in a task scheduled to run every 45 mins.
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 36900970
You can register the program as a service then set the properties if the service to restart the program when it crashes.  Here is a short page describing service recovery options.
http://www.itechtalk.com/thread1557.html
0
 

Author Comment

by:mcainc
ID: 36901049
I'm using task scheduler in windows 2008 to execute a bat file now... it appears to work perfectly when double clicking on it or running it from a command prompt... the problem is, when running it with task scheduler all of the processes start, but they are hidden (i.e., no gui is visible). the processes are working however.

is there a way to get around this? i've been fiddling with it for the last 30 minutes and i can't find any options that won't hide the processes in the background

this is what my batch file (respawn.bat) looks like:


taskkill /f /im csat.exe /t

start c:\apps\35\csat.exe
timeout 5 /nobreak
start c:\apps\36\csat.exe
timeout 5 /nobreak
start c:\apps\37\csat.exe

if i double click on respawn.bat, any existing processes are killed, and the 3 processes are restarted properly (gui is visible, etc).

if the scheduler runs respawn.bat, any existing processes are killed, and the 3 processes are stared, however they are not visible...

i need the gui's to be visible when they restart

pulling my hair out over this!
0
 

Author Comment

by:mcainc
ID: 36901059
ah i see... the only way to get it to run visibly is to "run only when user is logged in" otherwise the processes are hidden... makes sense


thanks guys!
0
 

Author Closing Comment

by:mcainc
ID: 36901060
this is what i needed!
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question