Monitoring process run time

Posted on 2005-04-28
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.

Question by:David Aldridge
    LVL 16

    Assisted Solution

    Have you tried going through this

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

    Author Comment

    by:David Aldridge
    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.
    LVL 28

    Accepted Solution

    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"
    LVL 1

    Author Comment

    by:David Aldridge
    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!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    perl rename 2 134
    Perl, group, sort, count question 6 101
    Perl DBI Transactions Using Custom Module 7 39
    Awk Question 2 106
    Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
    A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (,  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…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now