Reputation: 45
I need a shell script to list all the non used(running) pid files.
How can I check if the pid isn't running?
Upvotes: 0
Views: 460
Reputation: 133
Is this what you're looking for?
#!/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)
Upvotes: 1