简体   繁体   中英

kill one instance of ffserver out of multiple using specific configuration file

I have two instances of ffserver running both using different configuration file kept at different path. I want to kill one of them using a script. when i write following command :

    ps -ef |grep ffs

it gives output :

    root      6421  6394  0 18:47 pts/11   00:00:00 /root/bin/ffserver -f /root/newff/ffserver.conf
    root      6575  6562  0 18:49 pts/11   00:00:02 /root/bin/ffserver -f /root/test/downloaded/complete/ffserver.conf
    root      8453  3720  0 19:09 pts/11   00:00:00 grep ffs

Now i want to kill only one . Is there any way to kill using command name like i can give command name with kill

   pkill_like_command /root/bin/ffserver -f /root/newff/ffserver.conf

Please tell me how to do that as simple pkill will not work.

There is an -f switch that works for pkill , so that matching considers the full command line. You can test without killing using pgrep instead. So the command line would be for example (tested on Debian with procps 1:3.2.8-9):

pkill -f "ffserver.*/root/newff/ffserver.conf"

without pkill :

kill $( ps -ef | grep "ffserver.*/root/newff/ffserver.conf" | awk '{ print $2 }' )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM