Process: Use word-regexp to have a better match

pgrep doesn't offer such option.
This commit is contained in:
Jeremy Gardais 2023-08-14 18:38:13 +02:00
parent f370c8d6ab
commit 4ed375c01e
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 2 additions and 2 deletions

View File

@ -28,7 +28,7 @@ process_info() {
for PROCESS in ${PROCESS_LIST}; do
MSG="${MSG}${BLACKB}+ "
PRINTF_PROCESS=$(printf '%-22s' "${PROCESS}")
if (ps ax | grep -v grep | grep -E "${PROCESS}" > /dev/null); then
if (ps ax | grep --invert-match grep | grep --word-regexp "${PROCESS}" > /dev/null); then
MSG="${MSG}${WHITE}${PRINTF_PROCESS}${RESET}${BLACKB}= ${GREEN}RUNNING${RESET}"
else
MSG="${MSG}${WHITE}${PRINTF_PROCESS}${RESET}${BLACKB}= ${REDB}NOT RUNNING${RESET}"
@ -393,7 +393,7 @@ fi
# Process need a warning if running [[[
YELLOW_PROCESS='tmux screen glances htop automysqlbackup vzdump puppet aptitude'
for PROCESS in ${YELLOW_PROCESS}; do
if (ps ax | grep -v grep | grep "${PROCESS}" > /dev/null); then
if (ps ax | grep --invert-match grep | grep --word-regexp "${PROCESS}" > /dev/null); then
PRINTF_PROCESS=$(printf '%-22s' "${PROCESS}")
printf '%b' "\\n${BLACKB}+ ${WHITE}${PRINTF_PROCESS}${RESET}${BLACKB}= ${YELLOW}RUNNING${RESET}"
fi