-   Linux - General (
-   -   Shell Script : Kill a running process when another process starts (

ashmew2 08-18-2008 06: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.

gilead 08-19-2008 12:01 AM

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

pkill totem && firefox

ashmew2 08-20-2008 03: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 04: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.


All times are GMT -5. The time now is 07:59 PM.