LINUX 如何获取非 运行 PID-s?
LINUX How to get the non running PID-s?
我需要一个 shell 脚本来列出所有未使用的 (运行) pid 文件。
如何检查 pid 是否不是 运行?
这是您要找的吗?
#!/bin/bash
while read -d $'[=10=]' -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)
我需要一个 shell 脚本来列出所有未使用的 (运行) pid 文件。
如何检查 pid 是否不是 运行?
这是您要找的吗?
#!/bin/bash
while read -d $'[=10=]' -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)