From 4ed375c01e5a781586eea28ff8001de4a7c15cbf Mon Sep 17 00:00:00 2001 From: Gardouille Date: Mon, 14 Aug 2023 18:38:13 +0200 Subject: [PATCH] Process: Use word-regexp to have a better match pgrep doesn't offer such option. --- update-motd.d/20-service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update-motd.d/20-service b/update-motd.d/20-service index cc652a5..ede29dc 100755 --- a/update-motd.d/20-service +++ b/update-motd.d/20-service @@ -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