One Liner Tips : how to kill multiple process with just one line

Sometime , firefox did crash on me for don’t know what reason.
I think is because of Flash.. It was making some weird sound when tried to play a youtube video.

But even when pressed the close , exit button. (Quit_)
Upon trying to re-launch the firefox ..

something like this appear.

“there is another firefox process already running “

Hence, need to kill all Firefox process one by one.
So come the following …

$ ps xa| grep firefox| grep -v grep | awk '{print $1}' | xargs kill -9

So, after that you can re-launch the firefox again.
As it would no longer complain..

Get Free Email Updates!

Signup now and receive an email once I publish new content.

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Like

Related Post

2 Responses

  1. namran says:

    the above function can be simplified a but further with the following :

    #!/usr/bin/python
     
    def getBM (eng): 
        if eng == 'No rain':
            return "Tiada Hujan"
        if eng == 'Rain':
            return "Hujan"
        if eng == 'fair':
            return "Cerah" 
        if eng == 'Weather Fair':
            return "Cuaca Baik"
        if eng == 'Clear':
            return "Cerah"
        if eng == 'Hazy':
            return "Berjerebu"
        if eng == 'Windy':
            return "Berangin"
        if eng == 'No rain':
            return "Tiada Hujan"
        if eng == 'Cloudy':
            return "Mendung"
        if eng == 'Cloudy over coastal areas':
            return "Mendung di kawasan pantai"
        if eng == 'Cloudy over inland areas':
            return "Mendung di kawasan pedalaman"
        if eng == 'Rain':
            return "Hujan"
        if eng == 'Intermittent rain occasionally moderate':
            return "Hujan sekejap-sekejap kadangkala sederhana"
        if eng == 'Intermittent rain occasionally heavy':
            return "Hujan sekejap-sekejap kadangkala lebat"
        if eng == 'Windspread intermittent rain':
            return "Hujan sekejap-sekejap yang menyeluruh"
        if eng == 'Isolated rain':
            return "Hujan di satu dua tempat"
        if eng == 'Isolated rain over coastal areas':
            return "Hujan di beberapa tempat di kawasan pantai"
        if eng == 'Isolated rain over inland areas':
            return "Hujan di beberapa tempat di kawasan pedalaman"
        if eng == 'Scattered rain':
            return "Hujan curah/sementara di satu dua tempat"
        if eng == 'Scattered rain over coastal areas':
            return "Hujan curah/sementara di kawasan pantai"
        if eng == 'Scattered rain over inland areas':
            return "Hujan curah/sementara di kawasan pedalaman"
        if eng == 'Showers':
            return "Hujan curah"
        if eng == 'Isolated showers':
            return "Hujan curah di satu dua tempat"
        if eng == 'Isolated showers over coastal areas':
            return "Hujan curah di kawasan pantai"
        if eng == 'Isolated showers over inland areas':
            return "Hujan curah di kawasan pedalaman"
        if eng == 'Thunderstorms':
            return "Ribut petir"
        if eng == 'Isolated thunderstorms':
            return "Ribut petir di satu dua tempat"
        if eng == 'Scattered thunderstorms':
            return "Ribut petir di beberapa tempat"
        if eng == 'Widespread thunderstorms':
            return "Ribut petir di kebanyakan tempat"
        else:
            return eng
     
    # example usage : 
    print "translating 'No rain' = " + getBM("No rain")
    print "translating 'No rain' = " + getBM("Scattered thunderstorms")
    print "translating 'No rain' = " + getBM("Scattered rain over inland areas")

    hmm. if putting into a file and read from there would be much more better.

    Reply
  2. namran says:

    yeah..

    to make it read from a text file and behave exactly as above.

    #!/usr/bin/python
     
    import csv
    # to read from a file with list of weather.
    reader = csv.reader(open("weather_list.txt", "rb"), delimiter=':', quoting=csv.QUOTE_NONE)
    # build up a reference list
    kamus = {}
    for row in reader:
     english_w=row[0].lstrip(' ').strip(' ')
     bm_w=row[1].lstrip(' ').strip(' ')
     kamus[english_w] = bm_w
     
    # a function to return exactly the same
    def getBM (eng) :
     return kamus[eng]
    # example usage : 
    print getBM ("Isolated showers");
    print getBM ("Rain");

    then create text file with the following content.

    [namran@nb-namran Desktop]$ cat weather_list.txt 
    Weather Fair:Tiada Hujan
    Clear:Cerah
    Hazy:Berjerebu
    Windy:Berangin
    No rain:Tiada Hujan
    Cloudy:Mendung
    Cloudy over coastal areas:Mendung di kawasan pantai
    Cloudy over inland areas:Mendung di kawasan pedalaman
    Rain:Hujan
    Intermittent rain occasionally moderate:Hujan sekejap-sekejap kadangkala sederhana
    Intermittent rain occasionally heavy:Hujan sekejap-sekejap kadangkala lebat
    Widespread intermittent rain:Hujan sekejap-sekejap yang menyeluruh
    Isolated rain:Hujan di satu dua tempat
    Isolated rain over coastal areas:Hujan di beberapa tempat di kawasan pantai
    Isolated rain over inland areas:Hujan di beberapa tempat di kawasan pedalaman
    Scattered rain:Hujan curah/sementara di satu dua tempat
    Scattered rain over coastal areas:Hujan curah/sementara di kawasan pantai
    Scattered rain over inland areas:Hujan curah/sementara di kawasan pedalaman
    Showers:Hujan curah
    Isolated showers:Hujan curah di satu dua tempat
    Isolated showers over coastal areas:Hujan curah di kawasan pantai
    Isolated showers over inland areas:Hujan curah di kawasan pedalaman
    Thunderstorms:Ribut petir
    Isolated thunderstorms:Ribut petir di satu dua tempat
    Scattered thunderstorms:Ribut petir di beberapa tempat
    Widespread thunderstorms:Ribut petir di kebanyakan tempat
    Reply

Anything to add?

X