Kill python process with pkill python

I want to stop the python process in the script, but the first time I don't have any process, but I have to go through with my function reload:

function restart() {
   stop
   start
}
function start (){
exec ./server --db_host=.......
} 
function stop (){
pkill python
}

      

the problem is when i run it blocking so can you suggest me how to have a control like this

if [i have python process runing];then pkill python

      

thank

0


source to share


1 answer


This should do the trick



if [ `ps -e | grep python | wc -l` -gt 1 ]
then
    pkill python
if

      

0


source







All Articles