LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Shell Script : Kill a running process when another process starts (http://www.linuxquestions.org/questions/linux-general-1/shell-script-kill-a-running-process-when-another-process-starts-663557/)

ashmew2 08-18-2008 05:49 AM

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.

gilead 08-18-2008 11:01 PM

As a quick fix, you could change however you start firefox to something like this:
Code:

pkill totem && firefox

ashmew2 08-20-2008 02:26 AM

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 ?

bitpicker 08-20-2008 03:47 AM

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


All times are GMT -5. The time now is 07:38 AM.