?
Solved

Monitoring process run time

Posted on 2005-04-28
4
Medium Priority
?
188 Views
Last Modified: 2010-05-18
Is there a function or module that I can use to check the run time of a process on a Windows server so that I can kill it if it has exceeded a certain amount of time? If so, could you please point me in the right direction? I believe there is a tool in the resource kit that I could utilize, but I would like to not go external if there's a way for me to do it in perl.

Thanks!
holein5
0
Comment
Question by:David Aldridge
  • 2
4 Comments
 
LVL 16

Assisted Solution

by:manav_mathur
manav_mathur earned 186 total points
ID: 13892525
Have you tried going through this

http://search.cpan.org/~wyant/Win32-Process-Info-1.005/Info.pm

Sorry, but I wont be able to help further than looking thru CPAN, as I have never implemented this kind of thing.
0
 
LVL 1

Author Comment

by:David Aldridge
ID: 13894959
I got the win32-process-info module and I get a lot (read LOT) of information back from it , but I can't find the time running info.
0
 
LVL 28

Accepted Solution

by:
FishMonger earned 189 total points
ID: 13896237
The module won't give you the runtime directly, you'll need to calculated it based on the process "CeationDate" (i.e., subtract the CreationDate timestamp from the current time and output it in the desired format).  This example doesn't do the calculation but, should help.

use Win32::Process::Info;

$pi = Win32::Process::Info->new();
@info = $pi->GetProcInfo ();   # Get the max

for (0..$#info) {
   next unless defined $info[$_]{'Name'};
   print "Process ID: $info[$_]{'Handle'}\n";
   print "\tProcess Name: $info[$_]{'Name'}\n";
   print "\tProccess Created: " . scalar localtime($info[$_]->{'CreationDate'}) . "\n\n"
}
0
 
LVL 1

Author Comment

by:David Aldridge
ID: 13899409
I really appreciate you guys help. It looks like I will have to make a call to an external process. I have found "pslist" which looks like it might give me what I need. If you don't mind, I will split the points between you two.

Thanks for your help!
holein5
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

840 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