LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-31-2005, 04:23 PM   #1
hongman
Member
 
Registered: Feb 2005
Location: UK
Distribution: Knoppix 3.7
Posts: 285

Rep: Reputation: 35
Software to time termination


Hi all

Dont think I'll have any luck here, but I dont suppose anyone knows of any software that will kill an app at a certain time, or after x amount of mins/hrs, as gracefully as possible?

Thanks

Hong
 
Old 03-31-2005, 07:29 PM   #2
kramtoad
Member
 
Registered: Aug 2003
Posts: 38

Rep: Reputation: 15
How about a crontab entry:

kill -9 `ps a|grep process_name_to_kill|grep -v grep |cut -f1 -d" "`

Not exactly gracefull but it works.
 
Old 03-31-2005, 07:35 PM   #3
hongman
Member
 
Registered: Feb 2005
Location: UK
Distribution: Knoppix 3.7
Posts: 285

Original Poster
Rep: Reputation: 35
thanks!

whoa! what are the switches for that command?
 
Old 04-02-2005, 06:30 PM   #4
kramtoad
Member
 
Registered: Aug 2003
Posts: 38

Rep: Reputation: 15
The part in backtics gets executed and fed into the kill command.

ps: list the running processes
|: send the output to
grep: find everything that matches (the process name in question)
|: feed that into
grep -v grep: find everything that does not match "grep"
(since the first grep also results in finding itself)
|: feed the results into
cut -f1 -d' ': grab the first column with column seperators defined as a space

The result of all that is the process number to kill. Try experimenting with the individual commands and look at the man pages for each. Be careful what you use the kill command on!

Also, make sure the process you want to kill has a unique name or you may end up killing something else. Overall, I don't think this is the best way to do what you want but I don't know of any other way right offhand.

-Erik
 
Old 04-03-2005, 05:47 AM   #5
hongman
Member
 
Registered: Feb 2005
Location: UK
Distribution: Knoppix 3.7
Posts: 285

Original Poster
Rep: Reputation: 35
Thanks for the explanation kramtoad.

I'll have a play and see what I kill!!
 
Old 04-03-2005, 07:05 AM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Note that on most systems ' killall <your app name> ' should do the job
 
Old 04-03-2005, 07:37 AM   #7
hongman
Member
 
Registered: Feb 2005
Location: UK
Distribution: Knoppix 3.7
Posts: 285

Original Poster
Rep: Reputation: 35
Thanks.

I have tried to use the kill command before, but I couldnt work out the syntax. Always complained about a PID number or something...
 
  


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
software of time sync hongxing Linux - Software 5 10-12-2005 03:18 AM
Time planning software needed mcle Linux - Software 4 04-18-2005 10:23 AM
PPPD termination error in FC1 hemanthjjp Fedora 1 07-15-2004 06:31 PM
Linux process termination souvik Programming 1 04-12-2002 05:55 PM
termination 11 error cursedsnow Linux - Software 1 05-16-2001 06:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:31 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