The problem is the command might get stuck and I'm waiting hours for the command to finish which prevents other process to backlog as well. How can I determine, say if the command doesn't finished within 20 minutes, cancel the command and report the error that the command took too long.
-----Original Message----- From: Christopher Hahn [mailto:[EMAIL PROTECTED] Sent: Thursday, July 06, 2006 2:23 PM To: Wong, Danny H.; [email protected] Subject: RE: Find time it takes to run a command Just save the time() before and after and then turn the difference from seconds to what you need. i.e. $StartTime = time(); my output = `do sync $Project 2>&1`; $ElapsedTime = time() - $StartTime; $ElapsedTime = int($ElapsedTime/60) . " minutes and " . ($ElapsedTime%60) . " seconds"; HTH, Chris -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wong, Danny H. Sent: Thursday, July 06, 2006 2:05 PM To: [email protected] Subject: Find time it takes to run a command Hi Perl GURUS, Is there a module or a way to find out how long a command takes to finish? Example: my output = `do sync $Project 2>&1`; The program might hang for over 20 minutes. Is there a easy way to find out how the command takes? I want to cancel the command if it takes over a certain amount of time. Thanks! - - - - - Appended by Scientific Atlanta, a Cisco company - - - - - This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer. _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
