使用单行从ps命令中终止进程

时间:2015-10-08 12:47:50

标签: linux bash shell

从Windows执行bat文件:

ssh vagrant@192.x.x.x -i f:\id_rsa "scss --watch %1| kill -9 (ps -aux | grep scss | cut -d " " -f 4 | head -n 1)"

我想在执行scss命令后终止文件。或者可以在完成scss --watc ..命令后发送ctrl + c信号。

1 个答案:

答案 0 :(得分:0)

ssh vagrant@192.x.x.x  -i f:\id_rsa "scss --watch %1 && pgrep -f scss | xargs kill -9"

&&将阻塞,直到第一个命令完成执行。并且pgrep将通过关键字grep PID并使用管道发送kill命令来终止进程。

相关问题