Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to check how long time my program takes. Then I using "/usr/bin/time my_program". When it takes more than 5 seconds, I want to kill it. I tried "kill -9 TIME_S_PID", time is killed, but my_program is still running. So how to kill my_program?

Sorry, my English is really bad...

Thanks.

share|improve this question
    
A bit off topic here, but how do you find the PID of time? It doesn't show up with ps aux | grep time or in htop/top (running in another terminal) – Azz Oct 28 '10 at 8:05
up vote 1 down vote accepted

most unixes have pkill, which kills a process based on name Try: pkill my_program

/usr/bin/time my_program sleep 5 pkill -TERM my_program

Also, don't kill with -9. It doesn't allow cleanup.

share|improve this answer

I've never dabbled in unix but can't you just kill "my_program" instead of "time"? I would expect it to have it's own process id.

share|improve this answer
    
Yep, while I've been looking for time's PID, I found killing the process time is timing works a treat, and then time finishes up with it's summary information. – Azz Oct 28 '10 at 8:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .