Преглед изворни кода

Better way of finding the PID for ArchiveBot jobs

master
JustAnotherArchivist пре 6 година
родитељ
комит
64e815b9a5
1 измењених фајлова са 1 додато и 7 уклоњено
  1. +1
    -7
      kill-wpull-connections

+ 1
- 7
kill-wpull-connections Прегледај датотеку

@@ -21,13 +21,7 @@ then
fi fi
elif [[ "$1" == '-j' ]] elif [[ "$1" == '-j' ]]
then then
pids=($(pgrep --full "wpull.*$2"))

# Filter out this script; this is more complicated than it should be because you can't simply `| grep -v` the PID of this script. When you do that, you create a subshell, which you'd need to filter out as well.
# Instead, we convert the list to a string of the form " 1 2 3 ", then replace " PID " by a single space, and finally convert it back to an array for counting the remaining PIDs.
pids=" ${pids//$'\n'/ } "
pids=(${pids/ $$ / })

pids=($(pgrep --full "wpull.*/$2/"))
if [[ ${#pids[@]} -ne 1 ]] if [[ ${#pids[@]} -ne 1 ]]
then then
echo "Error: not exactly one process found for '$2'" echo "Error: not exactly one process found for '$2'"


Loading…
Откажи
Сачувај