Killing in the name of

Using psmisc in python i’ve found this function quite useful in many projects i’ve been working lately.

Basically it will kill all the process older than one hour that match “name”

All those try except are just to avoid permission denied on kill or on name check.

def killing_in_the_name_of(name):
    now = time.time()
    for p in psutil.get_process_list():
        exe = ""
        try:
            exe = p.exe
        except Exception,e:
            pass
        if name in exe:
            exetime = now - p.create_time
            if exetime > 3600.0:
                try:
                    p.kill()
                    print "killed %s ( %d s of execution time)"%(exe,exetime)
                except Exception,e:
                    print e

A suitable vimrc for python

Since i find myself in a lot of trouble when going to a new linux system due to misconfigured vim i thought

i might share with you my tipical default configuration for vim that is good for developing in python

here are the main lines, since i use a dark background i like a lot the “background=dark” feature

set compatible
syntax on
set background=dark
if has("autocmd")
  au BufReadPost * if line("'\"") > 0 && line("'\"") < = line("$")
    \| exe "normal g'\"" | endif
endif

set showcmd             
set showmatch           
set incsearch           

autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab " Python
autocmd FileType make set tabstop=8|set shiftwidth=8|set noexpandtab " Makefile
autocmd FileType man set tabstop=8|set shiftwidth=8|set noexpandtab " Man page (also used by psql to edit or view)
autocmd FileType calendar set tabstop=8|set shiftwidth=8|set noexpandtab

I hope this will help you too

Bio

Hello! i'm a Linux System Engineer, with high experience on Open Source
platforms and now a strong background on SRE.

If you need me, you can contact me:samu (at) samux.org

**Tools **

**Personal Projects **