LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-29-2007, 07:03 AM   #1
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: Arch Linux && OpenBSD 7.4 && Pop!_OS && Kali && Qubes-Os
Posts: 824

Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
[BASH]Timing an program, killing it after n seconds.


Hello all.

What would be the easiest way to measure the time that program has been running ?

I'm writing a script and that script invokes external programs and I need to shut them down after a few seconds,is there a built in timing mechanism in bash that I could use or do I have to write it myself ?

tia

////
 
Old 03-29-2007, 07:25 AM   #2
kshkid
Member
 
Registered: Dec 2005
Distribution: RHEL3, FC3
Posts: 383

Rep: Reputation: 30
if you need to shut them down after 'n' seconds,

Code:
./script &; sleep 10; kill -2 $!
 
Old 03-29-2007, 08:38 AM   #3
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: Arch Linux && OpenBSD 7.4 && Pop!_OS && Kali && Qubes-Os
Posts: 824

Original Poster
Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
thanks, I got it to work.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash: how to get time (in seconds) elapsed since creation of a file? J_Szucs Linux - General 6 12-27-2008 11:28 PM
how to start timing and print the timing result on portions of java codes ?? alred Programming 2 05-15-2006 10:00 AM
How to halt program for few seconds..??? asahlot Programming 11 10-20-2005 10:35 AM
Howto run a program for 15 seconds and let it quit itself. bglnelissen Programming 3 03-16-2005 09:37 AM
[bash] killing processes using ssh Erhnam Programming 13 01-31-2005 11:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration