简体   繁体   English

使用特定配置文件从多个中杀死一个ffserver实例

[英]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. 我有两个ffserver实例,两个实例都使用保存在不同路径的不同配置文件运行。 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 有没有什么方法可以使用命令名杀死,就像我可以给命令名加上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. 有一个-f开关适用于pkill ,因此匹配考虑整个命令行。 You can test without killing using pgrep instead. 您可以使用pgrep进行测试而不会杀死它。 So the command line would be for example (tested on Debian with procps 1:3.2.8-9): 因此,以命令行为例(在procps 1:3.2.8-9的Debian上进行了测试):

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

without pkill : 没有pkill

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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