| msevior ( @ 2008-08-13 13:06:00 |
Stupid script to kill evolution
Evolution has a number of great features that make it the best way to interface to our stupid MS Exchange server at work. However it does tend to hang on average once or twice a day while moving email back and forth to the Exchange IMAP service. At this point I find I need to find and kill all the separate processes used by evolution and restart. This got tedious enough that I wrote a stupid python script to do the work.
---------------------------------------- ---------------------------------------- ----
#!/usr/bin/python
#
# Remove all instances of evolution
#
import os
os.system('ps -aux | grep -i evo | cat > /tmp/killevo.txt')
fs = open('/tmp/killevo.txt')
ll = fs.readlines()
for l in ll:
bignore = 0
l.expandtabs()
lc = ''
bsp = 0
for c in l:
if((bsp == 0) or (c != ' ')):
lc = lc + c
if c == ' ':
bsp = 1
else:
bsp = 0
ls = lc.split(' ')
pid = ''
for ss in ls:
if ss == 'grep' or ss == 'emacs' or (ss.find('killevo') > -1):
bignore = 1
pid = ls[1]
if bignore == 0:
kills = 'kill -9 '+pid
print 'Executing.. ',kills
os.system(kills)
fs.close()
os.system('rm /tmp/killevo.txt')
---------------------------------------- ---------------------
I'm 100% certain that a real python/perl/bash hacker could this in 1/3rd the LOC but hey it works :-)
Evolution has a number of great features that make it the best way to interface to our stupid MS Exchange server at work. However it does tend to hang on average once or twice a day while moving email back and forth to the Exchange IMAP service. At this point I find I need to find and kill all the separate processes used by evolution and restart. This got tedious enough that I wrote a stupid python script to do the work.
----------------------------------------
#!/usr/bin/python
#
# Remove all instances of evolution
#
import os
os.system('ps -aux | grep -i evo | cat > /tmp/killevo.txt')
fs = open('/tmp/killevo.txt')
ll = fs.readlines()
for l in ll:
bignore = 0
l.expandtabs()
lc = ''
bsp = 0
for c in l:
if((bsp == 0) or (c != ' ')):
lc = lc + c
if c == ' ':
bsp = 1
else:
bsp = 0
ls = lc.split(' ')
pid = ''
for ss in ls:
if ss == 'grep' or ss == 'emacs' or (ss.find('killevo') > -1):
bignore = 1
pid = ls[1]
if bignore == 0:
kills = 'kill -9 '+pid
print 'Executing.. ',kills
os.system(kills)
fs.close()
os.system('rm /tmp/killevo.txt')
----------------------------------------
I'm 100% certain that a real python/perl/bash hacker could this in 1/3rd the LOC but hey it works :-)