One issue, not germane to OP's problem, is
1.
2. pkill belongs to the procps package, which is not a dependency of recmon. The script could use
Or make procps a dependency. Or use kill_by_pathregex, something like:
/mod//etc/init.d/S54recmon: line 32: pkill: not found
1.
/mod//...
?2. pkill belongs to the procps package, which is not a dependency of recmon. The script could use
killall recmon
instead, although that will kill all processes named recmon
.
Code:
# pkill --help
pkill: invalid option -- -
Usage: pkill [-SIGNAL] [-fvx] [-n|-o] [-P PPIDLIST] [-g PGRPLIST] [-s SIDLIST]
[-u EUIDLIST] [-U UIDLIST] [-G GIDLIST] [-t TERMLIST] [PATTERN]
# /bin/killall --help
BusyBox v1.20.2 (2014-05-13 23:10:17 BST) multi-call binary.
Usage: killall [-l] [-q] [-SIG] PROCESS_NAME...
#
Code:
kill_by_pathregex() { # name kill_args...
victim=$1; shift
for f in grep -l -s -E "^${victim}\$" /proc/*/cmdline; do
p=${f#/proc/}; p=${p%%*}
# chattier: change continue to 'echo "Failed to kill $f ($p)" 1>&2'
kill "$p" "$@" || continue
done
}