Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11th May 2012, 11:12 AM
COKEDUDE Offline
Registered User
 
Join Date: Jan 2011
Posts: 276
linuxfirefox
kill a process in a certain amount of time

I would like to kill a process in a certain amount of time. Can I please get some ideas on how to do this?
Reply With Quote
  #2  
Old 11th May 2012, 12:37 PM
jpollard Online
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,150
linuxfirefox
Re: kill a process in a certain amount of time

Which time? CPU utilization, elapsed, or wait time?

usually the last is a failure of the application to account for I/O delays and attempting to use asynchronous I/O improperly (not my area of expertise though).

Need more information - what are you trying to do?
Reply With Quote
  #3  
Old 11th May 2012, 02:26 PM
jsp Offline
Registered User
 
Join Date: Feb 2009
Posts: 34
linuxchrome
Re: kill a process in a certain amount of time

you can schedule stuff with at, like

Code:
$at now + 5 minutes
at>killall myprocess
at> CTRL-D
job 77 at Fri May 11 08:22:00 2012
Reply With Quote
  #4  
Old 11th May 2012, 09:31 PM
COKEDUDE Offline
Registered User
 
Join Date: Jan 2011
Posts: 276
linuxfirefox
Re: kill a process in a certain amount of time

Quote:
Originally Posted by jpollard View Post
Which time? CPU utilization, elapsed, or wait time?

usually the last is a failure of the application to account for I/O delays and attempting to use asynchronous I/O improperly (not my area of expertise though).

Need more information - what are you trying to do?
Sometimes I want it to be 10 minutes, sometimes I want it to be 20 minutes, etc. I would like a method that is easy to change with different amounts of time.
Reply With Quote
  #5  
Old 11th May 2012, 09:42 PM
dd_wizard's Avatar
dd_wizard Offline
Registered User
 
Join Date: Sep 2009
Posts: 1,409
linuxfedorafirefox
Re: kill a process in a certain amount of time

Try this:
Code:
CommandYouWantToRun & sleep 10m; kill %+
This starts CommandYouWantToRun in background, then sleeps 10 minutes, then kills the "current job".

dd_wizard

Last edited by dd_wizard; 11th May 2012 at 10:05 PM.
Reply With Quote
  #6  
Old 11th May 2012, 09:57 PM
jpollard Online
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,150
linuxfirefox
Re: kill a process in a certain amount of time

Welll... one way is to do something like:
Code:
$ coproc sleep 100
$ sleep 20
$ kill -9 $COPROC_PID
The "sleep 100" is the command to be timed. The "sleep 20" is the time to wait for it before aborting it.

The "kill -9 $COPROC_PID" aborts the coprocess pid (which is the "sleep 100" line).

If the timed command terminates before the kill command then the kill will get "no such process" error.

You can lookup the coproc and is assocated PID handling in the manpage on bash.
Reply With Quote
Reply

Tags
kill, process, time

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run process from C++ and kill it after some time monk.pt Programming & Packaging 5 26th May 2009 06:21 PM
USB Storage fails after some amount of time in F7 blacktek Hardware & Laptops 6 16th November 2007 09:45 AM
How do I kill a process? Sunnz Using Fedora 8 14th July 2005 03:16 AM
FC2 stops routing properly after random amount of time ajwutila Servers & Networking 3 3rd November 2004 01:15 AM


Current GMT-time: 10:04 (Wednesday, 19-06-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat