LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-18-2008, 05:49 AM   #1
ashmew2
LQ Newbie
 
Registered: Aug 2008
Posts: 2

Rep: Reputation: 0
Shell Script : Kill a running process when another process starts


Hi , I was wondering if i could kill an already running process when i start another one.

For example ,
If i run firefox , i want that totem be killed before firefox starts( Because if totem is running , firefox doesnt play any sound ).
How can this be achieved ?

I hope Im clear with my query.
Thanks.
 
Old 08-18-2008, 11:01 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
As a quick fix, you could change however you start firefox to something like this:
Code:
pkill totem && firefox
 
Old 08-20-2008, 02:26 AM   #3
ashmew2
LQ Newbie
 
Registered: Aug 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for the info , but i cant figure out how to add this to firefox startup , Im using Ubuntu Hardy and running Firefox from
Applications > Internet > Firefox . Any ideas ?
 
Old 08-20-2008, 03:47 AM   #4
bitpicker
Member
 
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416
Blog Entries: 14

Rep: Reputation: 35
The Firefox icon you are using has a setting entry in its right-click menu. There, you can replace the current command with what gilead said.

However, 'pkill totem' will return a failed exit code if totem isn't running. The && operator will then fail to start Firefox because it will only execute the command if the previous command returned no error. Replace the && with a ; instead. This way the two commands will simply be executed in sequence, regardless of whether pkill finds a totem to kill or not.

Robin
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to stop a process running in background (on a shell script) Azk00 Linux - Newbie 3 02-01-2008 04:24 AM
kill the process invoked from a shell script, when the script is killed kskkumar Linux - Software 8 05-23-2007 11:29 AM
Shell Script to kill a process automaticaly brazilian_user Programming 11 06-12-2006 09:09 PM
kill process and its child in a shell dalmassoc Linux - Software 4 03-03-2006 01:57 AM
Kill a process launched by a shell script gsbarry Programming 7 01-06-2004 02:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:12 AM.

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