Jef*_*ang 5 python linux bash raspberry-pi3
我运行一个bash脚本,启动一个python脚本在后台运行
#!/bin/bash
python test.py &
Run Code Online (Sandbox Code Playgroud)
那我怎么能用bash脚本杀死脚本呢?
我使用以下命令来杀死但输出 no process found
killall $(ps aux | grep test.py | grep -v grep | awk '{ print $1 }')
Run Code Online (Sandbox Code Playgroud)
我尝试检查正在运行的进程ps aux | less
,发现运行脚本有命令python test.py
请帮忙,谢谢!
Ini*_*ian 22
使用pkill
命令为
pkill -f test.py
Run Code Online (Sandbox Code Playgroud)
(或)pgrep
用于搜索实际进程ID的更简单的方法
kill $(pgrep -f 'python test.py')
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12855 次 |
最近记录: |