我需要一个shell脚本来列出所有未使用(正在运行)的pid文件。
如何检查pid是否未运行?
最佳答案
这就是你要找的吗?
#!/bin/bash
while read -d $'\0' -r f; do
pid="$(cat "$f")"
if ! ps "$pid" &> /dev/null; then
echo "$pid"
fi
done < <(find /run -type f -regextype posix-basic -regex '^.*\.pid$' -print0)
关于linux - LINUX如何获取未运行的PID?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36186040/